Subject Re: Grid search
From Akshat Kapoor <akshat.kapoor@kapoorsons.in>
Date Fri, 25 Sep 2020 19:07:04 +0530
Newsgroups dbase.getting-started
Attachment(s) test_requery.wfm

> Now I just need to figure out how to catch the keys typed when the grid
> has focus.
> Thinking of a form variable to accumulate the keys typed within a short
> period of time. This would get wiped after a certain pause.
> Accumulate keys and perform a search after a pause.
>
> Thing is, dBase can't cancel a running search when a new key sequence is
> typed - mmm
>
> Perhaps this is the point when I drop this line of exploration.
> Thinking I would need to create a Thread that could be terminated at will.
>
> SeekerSQL it is...
>
> Appreciate your interest and feedback
> Your code is a delight to read

Good Evening Ronnie,
Placing a entryfield near the grid and then searching is damn easier
than grid having focus and searching.
Grid doesnot have a onKey event.

Moreover size of rowset will also be an issue.

As searching all columns can never be an indexed search.
And once this loop starts it may be difficult to break.

I have used my code with a 4-5k rows and it takes time to scroll and
search.

I was searching for amounts also so I had to include all columns. In
your case if it is just 2 or 3 columns then it would be easier to add a
calculated field index it and search for it.

I have attached another test code developed for demo only. It is not a
production version.
The earlier code was a deployed code.
But still will give you ideas.

Regards
Akshat



** END HEADER -- do not remove this line
//
// Generated on 31-08-2020
//
parameter bModal
local f
f = new test_requeryForm()
if (bModal)
   f.mdi = false // ensure not MDI
   f.readModal()
else
   f.open()
endif

class test_requeryForm of FORM
   with (this)
      height = 23.9545
      left = 9.8571
      top = 0.0
      width = 119.5714
      text = ""
   endwith

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

   this.CUSTOMERS1 = new QUERY(this)
   with (this.CUSTOMERS1)
      left = 18.0
      top = 2.0
      width = 9.0
      height = 1.0
      database = form.dbasesamples1
      sql = "select * from CUSTOMERS.DBF where lower(company) like :cstr"
      params["cstr"] = "%"
      active = true
   endwith

   this.GRID1 = new GRID(this)
   with (this.GRID1)
      dataLink = form.customers1.rowset
      allowEditing = false
      anchor = 1        // Bottom
      height = 14.0
      left = 0.0
      top = 9.8636
      width = 119.2857
   endwith

   this.ENTRYFIELD1 = new ENTRYFIELD(this)
   with (this.ENTRYFIELD1)
      onKey = class::ENTRYFIELD1_ONKEY
      height = 1.0
      left = 37.0
      top = 3.5
      width = 33.0
      value = ""
   endwith


   function ENTRYFIELD1_onKey(nChar, nPosition,bShift,bControl)
      form.customers1.params["cstr"] = lower(ltrim(rtrim(this.value))+ "%")
      form.customers1.requery()
      return

endclass