Subject Re: Seeker and GridColumnIndexChange.cc
From Mervyn Bick <invalid@invalid.invalid>
Date Tue, 4 May 2021 10:05:50 +0200
Newsgroups dbase.getting-started
Attachment(s) test_seeker.wfmtest_seeker1.wfmtest_seeker2.wfm

On 2021/05/04 02:06, roy price wrote:
> Hopefully one last problem.....

We've also got our fingers crossed for you but remember that there isn't
a limit on the number of questions you may ask.  The only silly question
is the one you don't ask. :-)

> My form uses Gridcolumnindexchange.cc, and I wish to include a seeker as part of the form, but cannot see how to combine Seeker with gridcolumnindex change.

In practice, one can only have one Seeker control on a form as it uses
the current index for the rowset assigned to the form's rowset property.
  The index expression must be based on the upper() function.

In theory (I haven't actually tried this) if you change the index the
Seeker control should use the new index (if it is based on upper() )
automatically.

I assume (my favourite exercise - jumping to conclusions :-) ) that, as
you are using a separate from at the moment, you always want the Seeker
control to use a specific index.  If this is the case the use of
Gridcolumnindexchange.cc causes problems.

One possible solution is to use a separate query to drive the Seeker and
use that rowset's onNavigate event handler to locate the corresponding
record in the main rowset.  This will work and is demonstrated in the
attached example, test_seeker.wfm.  It is, however, less than ideal as
you won't see the search field in alphabetical order as you enter
additional characters.

> So my approach is to include a button on the form that runs a separate seeker form with the same table, does a seek, and stores the record number of the table  to a variable, close the Seeker Form, and then use the variable to navigate the table to the same record number.
> As with the following, that does produce an error, but doesn't navigate either, as I cannot see how to navigate just by closing the seeker form.
> ?I need something to "trigger" the navigate.
>
> function SEEKERTITLE85_onClick()
>        Do seekertitle85.wfm
>        return
>
>   function SEEKERREC_onClose()
>       Store Rec to mrec
>     this.cactusaa1.rowset.applyLocate( mRec)
>        return
>
> function form_onNavigate(nWorkArea)
>         this.image1.dataSource = "FILENAME
> "+form.cactusaa1.rowset.fields['photoloc'].value
> return

form_onNavigate(nWorkArea) is intended for use where the .dbf file has
been opened in a workarea by using the USE command.  It is an XDML
command and shouldn't be used with tables opened using OODML.

I suggest that you stick with a separate form for the Seeker control but
that you open it using the readModal() method i.e Do seekertitle85.wfm
with true

This means that your main program stops until you close the search form
and then continues where it left off.

In seekertitle85.wfm use it's onClose event handler to save a unique
value from the record selected to a user-defined property of the _app
object.  This is effectively the same as using a global variable.

When the seeker form has closed the value in the _app property can be
used to navigate to the correct record in the main table.

Run test_seeker.wfm before you run test_seeker1.wfm as it creates the
index needed for the seeker.

In test_seeker2.wfm the customerID is saved to _app.seek_record.  This
is a numeric field. If you save a character field the applyLocate()
instruction in test_seeker1.wfm should look like

form.rowset.applyLocate( "whatever = '" + _app.seek_record.value+"'" )

Mervyn.











use :dbasesamples:customers excl
index on upper(company) tag upco
use
** END HEADER -- do not remove this line
//
// Generated on 2021-05-04
//
parameter bModal
local f
f = new test_seekerForm()
if (bModal)
   f.mdi = false // ensure not MDI
   f.readModal()
else
   f.open()
endif

class test_seekerForm of FORM
   set procedure to :FormControls:seeker.cc additive
   with (this)
      onOpen = class::FORM_ONOPEN
      height = 25.0
      left = 9.7143
      top = 1.6364
      width = 108.1429
      text = ""
   endwith

   this.DBASESAMPLES1 = new DATABASE(this)
   with (this.DBASESAMPLES1)
      left = 5.0
      width = 11.0
      height = 1.0
      databaseName = "DBASESAMPLES"
      active = true
   endwith

   this.CUSTOMERS1 = new QUERY(this)
   with (this.CUSTOMERS1)
      left = 18.0
      width = 9.0
      height = 1.0
      database = form.dbasesamples1
      sql = "select * from CUSTOMERS.DBF"
      active = true
   endwith

   with (this.CUSTOMERS1.rowset)
      indexName = "CITY"
   endwith

   this.CUSTOMERS2 = new QUERY(this)
   with (this.CUSTOMERS2)
      left = 30.0
      width = 9.0
      height = 1.0
      database = form.dbasesamples1
      sql = "select * from CUSTOMERS.DBF"
      active = true
   endwith

   with (this.CUSTOMERS2.rowset)
      onNavigate = class::ROWSET_ONNAVIGATE
   endwith

   this.GRID1 = new GRID(this)
   with (this.GRID1)
      dataLink = form.customers1.rowset
      height = 7.9545
      left = 2.1429
      top = 4.5
      width = 50.0
   endwith

   this.GRID2 = new GRID(this)
   with (this.GRID2)
      dataLink = form.customers2.rowset
      height = 7.6364
      left = 58.4286
      top = 4.6364
      width = 47.1429
   endwith

   this.SEEKER1 = new SEEKER(this)
   with (this.SEEKER1)
      height = 1.0
      left = 20.0
      top = 15.7727
      width = 24.5714
   endwith

   this.TEXT1 = new TEXT(this)
   with (this.TEXT1)
      height = 3.0
      left = 59.5714
      top = 0.2727
      width = 43.5714
      text = "This grid is for the example only.  It is used to show the Seeker in operation.  Any records selected here is then used to move to the rowpointer in the main rowset."
   endwith

   this.rowset = this.customers1.rowset

   function form_onOpen()
      form.customers2.rowset.indexName := "upco"
      form.rowset = this.customers2.rowset
      return

   function rowset_onNavigate(type, nRows)
      this.parent.parent.customers1.rowset.applyLocate( "CustomerID = " + this.fields['CustomerID'].value )
      return

endclass



** END HEADER -- do not remove this line
//
// Generated on 2021-05-04
//
parameter bModal
local f
f = new test_seeker1Form()
if (bModal)
   f.mdi = false // ensure not MDI
   f.readModal()
else
   f.open()
endif

class test_seeker1Form of FORM
   with (this)
      height = 16.0
      left = 58.0
      top = 2.5455
      width = 52.1429
      text = ""
   endwith

   this.DBASESAMPLES1 = new DATABASE(this)
   with (this.DBASESAMPLES1)
      left = 14.0
      width = 11.0
      height = 1.0
      databaseName = "DBASESAMPLES"
      active = true
   endwith

   this.CUSTOMERS1 = new QUERY(this)
   with (this.CUSTOMERS1)
      left = 5.0
      width = 9.0
      height = 1.0
      database = form.dbasesamples1
      sql = "select * from CUSTOMERS.DBF"
      active = true
   endwith

   this.GRID1 = new GRID(this)
   with (this.GRID1)
      dataLink = form.customers1.rowset
      height = 10.4545
      left = 3.8571
      top = 2.0
      width = 43.8571
   endwith

   this.PUSHBUTTON1 = new PUSHBUTTON(this)
   with (this.PUSHBUTTON1)
      onClick = class::PUSHBUTTON1_ONCLICK
      height = 1.0909
      left = 15.7143
      top = 13.5909
      width = 19.4286
      text = "Open search Form"
   endwith

   this.rowset = this.customers1.rowset

   function PUSHBUTTON1_onClick()
      do test_seeker2.wfm with true
      form.rowset.applyLocate( "CustomerID = " + _app.seek_record.value )
      return

endclass



** END HEADER -- do not remove this line
//
// Generated on 2021-05-04
//
parameter bModal
local f
f = new test_seeker2Form()
if (bModal)
   f.mdi = false // ensure not MDI
   f.readModal()
else
   f.open()
endif

class test_seeker2Form of FORM
   set procedure to :FormControls:seeker.cc additive
   with (this)
      onOpen = class::FORM_ONOPEN
      onClose = class::FORM_ONCLOSE
      height = 16.0
      left = 71.7143
      top = 4.0
      width = 52.1429
      text = ""
   endwith

   this.DBASESAMPLES1 = new DATABASE(this)
   with (this.DBASESAMPLES1)
      left = 14.0
      width = 11.0
      height = 1.0
      databaseName = "DBASESAMPLES"
      active = true
   endwith

   this.CUSTOMERS1 = new QUERY(this)
   with (this.CUSTOMERS1)
      left = 5.0
      width = 9.0
      height = 1.0
      database = form.dbasesamples1
      sql = "select * from CUSTOMERS.DBF"
      active = true
   endwith

   with (this.CUSTOMERS1.rowset)
      indexName = "UPCO"
   endwith

   this.GRID1 = new GRID(this)
   with (this.GRID1)
      dataLink = form.customers1.rowset
      height = 8.9545
      left = 3.8571
      top = 2.0
      width = 43.8571
   endwith

   this.PUSHBUTTON1 = new PUSHBUTTON(this)
   with (this.PUSHBUTTON1)
      onClick = class::PUSHBUTTON1_ONCLICK
      height = 1.0909
      left = 15.7143
      top = 13.5909
      width = 19.4286
      text = "Return to main form"
   endwith

   this.SEEKER1 = new SEEKER(this)
   with (this.SEEKER1)
      height = 1.0
      left = 14.8571
      top = 11.7727
      width = 20.2857
   endwith

   this.rowset = this.customers1.rowset

   function PUSHBUTTON1_onClick()
      form.close()
      return

   function form_onClose()
      _app.seek_record = this.rowset.fields['customerid'].value
      return

   function form_onOpen()
      this.seeker1.setfocus()
      return

endclass



Warning: Unknown: write failed: No space left on device (28) in Unknown on line 0

Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct () in Unknown on line 0