best way to filter a datagrid

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm

best way to filter a datagrid

Post by townsend » Fri Nov 29, 2013 6:01 pm

I've got a datagrid with a date column. Some rows have a date, and others have the date field as empty.

I don't want to display both the empty and populated fields at the same time.
So I have a couple of radio buttons set up to switch back and forth between views.

The problems is, what's the best way make some rows "not visible" based on the value of this 1 field?
Here's an example, by extracting the data to do a filter and then re-populating the table.

Code: Select all

put the dgText of grp "DataGrid" into tText 
put fld "Search field" into tSearch 
filter tText with ("*" & tSearch & "*") 
## or whereever you need the "wildcards" -> * 

set the dgText of fld "DataGrid" to tText 
Is there a better way to do this? Thanks-- appreciate the pointers.

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: best way to filter a datagrid

Post by bangkok » Fri Nov 29, 2013 7:35 pm

I believe there is.

By changing the default behavior of the DG.

http://lessons.runrev.com/s/3527/m/data ... -to-a-cell

In the FillInData handler :

Code: Select all

on FillInData pData
   -- This message is sent when the Data Grid needs to populate
   -- this template with the column data. pData is the value to be displayed.

if XXXXXXX then set the text of me to pData

end FillInData
You have to try. But It might create empty lines.

Post Reply