Subject Re: Grid doesn't refresh in form
From Paul Nielsen <invalid@invalid.com>
Date Tue, 12 Jul 2016 14:51:18 -0400
Newsgroups dbase.getting-started

My thanks to both you and Ken Mayer for quick replies.

I modified the pushbutton function to:

   function PUSHBUTTON1_onClick
      form.query1.params["dBegin"] := form.entryfield1.value
      form.query1.params["dEnd"]   := form.entryfield2.value
* added 20160712 per Mervyn Bick
       form.query1.requery()
       form.grid1.datalink = form.query1.rowset
       form.grid1.columns["Column1"].dataLink = form.query1.rowset.fields["Invoice ID"]
       form.grid1.columns["Column2"].dataLink = form.query1.rowset.fields["order date"]
       form.grid1.columns["Column3"].dataLink = form.query1.rowset.fields["customer ID"]
       form.grid1.refresh()
* end of additions

set talk on
?form.query1.params["dBegin"]
?form.query1.params["dEnd"]
set talk off
   return

This now works. I think the addition of the line 'form.grid1.requery()' forces immediate display of the grid data, without it, the grid is empty, except for the first invoice ID, but when the slider bar at the bottom of the area for the grid is moved all the way to the right, the grid refreshes anyway.

As Ken hinted at, the addition of the four lines

       form.grid1.datalink = form.query1.rowset
       form.grid1.columns["Column1"].dataLink = form.query1.rowset.fields["Invoice ID"]
       form.grid1.columns["Column2"].dataLink = form.query1.rowset.fields["order date"]
       form.grid1.columns["Column3"].dataLink = form.query1.rowset.fields["customer ID"]

is essential to have the data appear in the grid.

My thanks to both you and Ken Mayer for quick replies.

Mervyn Bick Wrote:

> On 7/7/2016 8:22 PM, Paul Nielsen wrote:
> > The intermediate level example of passing parameters in params.wfm doesn't properly refresh the grid display of the data.
> >
> > (params.wfm is on the CD at .\kb\int\code_tips_tricks_advice\tips.zip)
> >
> > I made a 4 column version with some additional outputs for test also. params.wfm, my version paramspn.wfm, and the invoice.dbf are included in the attached zip file.
> >
> > What is missing to make the grid refresh?
> >
> > I've tried some things like adding form.query1.rowset.first() when the button is pressed, but nothing I've tried works.
> >
> > (I'm running version 2.61 of dBase Plus with all patches.)
> >
>
> Your forms works perfectly in dBASE 10.3.1.
>
> Unfortunately I no longer have dBASE 2.61 available but I do seem to
> recall that there were problems with refreshing the grid where its
> columns property was used to select columns.
>
> Try restating all the data links in the pushbutton's onClick event
> handler after the requery.  The form.grid1.refresh(() may not be necessary.
>
>
>      function PUSHBUTTON1_onClick
>        form.query1.params["dBegin"] := form.entryfield1.value
>        form.query1.params["dEnd"]   := form.entryfield2.value
>        form.query1.requery()
>        form.grid1.datalink = form.query1.rowset
>        form.grid1.columns["Column1"].dataLink =
> form.query1.rowset.fields["Invoice ID"]
>        form.grid1.columns["Column2"].dataLink =
> form.query1.rowset.fields["order date"]
>        form.grid1.columns["Column3"].dataLink =
> form.query1.rowset.fields["customer ID"]
>        form.grid1.refresh()
>        return
>
>
> Mervyn.
>