Page 1 of 1

Data Grid API - FindIndex pKey, pSearchString

Posted: Tue Dec 01, 2009 12:29 pm
by dickey
Hello All,

I was hoping to use FindIndex as a stepping stone to implementing multi-column filtering functionality for my Data Grid.

I was hoping to filter the contents of a single column of my Data Grid like so:

Code: Select all

 dispatch "FindIndex" to group "DataGrid 1" with "Col 2", "Mi*"
 put the result into tIndexes  
 repeat for each item tIndex in tIndexes
   answer info tIndex -- for testing only, will contain code to update the display of the Data Grid based on an array of matching indexes
 end repeat
I had considered that pSearchString would be passed the values the user types in the column specific filter (field), and that like in the above example if a user typed Mi* my code would look in Col 2 of my Data Grid and return an array of Data Grid indexes that matched the wildcard search.

Two problems arise:

1. FindIndex appears only to look for a single (perhaps first) match,
2. Wild cards like * do not seem to work. "Mi*" results in index 0 (no match), whereas "Mitchell" results in index 4 (Line 4, Column 2 of the DataGrid contains the name Mitchell).

I do know how to filter the grid (based on the content of all columns) using:

Code: Select all

   put the dgText of grp "DataGrid 1" into tText
   put fld "fldFilterFirstName" into tFilter
   filter tText with ("*" & tFilter & "*")
   set the dgText of grp "DataGrid 1" to tText
, that is not the issue. I need be able to filter the data using criteria (with wildcards) for each column against the content of each column. As FindIndex supports multiple pkey and pSearchString, it seemed the likely solution until I hit the issues raised above. For instance a direct match like

Code: Select all

dispatch "FindIndex" to group "DataGrid 1" with "Col 2", "Mitchell", "Col 3", "Melbourne"
does work on a single matching row, returning its id, being 4, so perhaps there is a way forward and I merely have the syntax wrong.

Building multi-column filtering is important to me, as I am analysing large datasets (1 million +) records with my DataGrids.

Perhaps I have the wrong approach to the multi-column filter challenge?

Any assistance greatly appreciated.

Kind regards, Andrew

PS: calling/channeling Trevor Devore?

Re: Data Grid API - FindIndex pKey, pSearchString

Posted: Tue Dec 01, 2009 3:51 pm
by trevordevore
FindIndex is an exact match. You would have to dive into the Data Grid code yourself if you wanted to look at adding wildcards. Edit script of btn "Data Grid" of stack "revDataGridLibrary".

How are you storing your million + records? Database? If so I would perform the matching in the database. If it is just text files then I will be interested to hear what performance is like when loading that much data into a Data Grid all at once.

Re: Data Grid API - FindIndex pKey, pSearchString

Posted: Tue Dec 01, 2009 9:36 pm
by dickey
Thank you very much for replying Trevor (most appreciated),

My company's main products are business directories (and tactical subsets of data by taxonomy or geographic location-territory). Therefore depending on the country (datasets can range from the 10's of thousands to millions of records).

Generally with these large datasets we use a MySQL backends, so in such cases the filtering/searching (locating matching businesses by name, place, telephone etc) of really large datasets can be pushed back to the database. I have that working.

I have studied your lesson on 'displaying large amounts of data' and have implemented:

command GetDataForLine pLine, @pDataA
end GetDataForLine

but shy away from it for anything other than 'read only' displays of data, because in most other situations I generally need to access the properties like dgData. In cases where I work closely with or edit the data, I generally edit record sets of around 5000 records, per time.

I don't have a definitive number of records at which point performance degrades. Generally we have datasets and datagrids with between 6-50 columns per grid, so the row size varies greatly.

I have not seen a point yet where performance is ever unacceptable.

In my post I was just wondering whether based on a dataset of reasonable size I could perform multi-column filtering using the API perhaps using FindIndex (without a db - in circumstances where I was using a text or an xml file as record source). When I have a chance I will edit the script of btn "Data Grid" to see if I can get that to work. For smaller apps I figured that sort of functionality might be nice.

I was actually just replicating some functionality, I use on the web with dhtmlx's grid component http://www.dhtmlx.com/docs/products/dht ... ndex.shtml.

Thanks again Trevor, (and seeing as the calendar has reached December) - Merry Christmas.

Kind regards, Andrew