Page 1 of 1
Searching a Datagrid
Posted: Fri Jan 24, 2014 5:01 pm
by altamative131
Hello LiveCode pimps!!!
I have an issue that I am trying to figure out a solution to...and I require your assistance if you would be so kind.
I have 2 datagrids. One datagrid contains all of my saved data, the second is going to be to display searched data from the first one. My question is, how in the heck do I go about doing that?
The datagrid with all of my information is going to be on a "hidden" card and the display datagrid will be on a public "reporting" card.
my question is how do I search for a specific string on the first datagrid, and have it display the entire line that string is on and all instances of that string.
Any help would be much appreciated.
Thanks!
Re: Searching a Datagrid
Posted: Fri Jan 24, 2014 5:14 pm
by Klaus
HI altamative131,
if your datagrid is of type TABLE, you could do something like this:
Code: Select all
...
put "whatever" into tSearchString
## Now put all data into a variable:
put the dgtext of grp "the hidden one with all your data in it" of cd "a card with a hidden datagrid" into tData
## Now use FILTER to get all lines with the searchstring in them:
filter tData with ("*" & tSearchString & "*")
if tData = empty then
answer "No matching data!"
exit to top
end if
## Finally put found data into other datagrid
set the dgdata of grp "data display" to tData
...
You get the picture
Best
Klaus
Re: Searching a Datagrid
Posted: Fri Jan 24, 2014 6:12 pm
by dunbarx
Pimps?
Craig
Re: Searching a Datagrid
Posted: Fri Jan 24, 2014 6:17 pm
by Klaus

- LCpimp.jpg (31.03 KiB) Viewed 6564 times
dunbarx wrote:Pimps?
Craig
Yep, that's me!

Re: Searching a Datagrid
Posted: Fri Jan 24, 2014 10:31 pm
by LC4iOS
Klaus wrote:HI altamative131,
if your datagrid is of type TABLE, you could do something like this:
Code: Select all
...
put "whatever" into tSearchString
## Now put all data into a variable:
put the dgtext of grp "the hidden one with all your data in it" of cd "a card with a hidden datagrid" into tData
## Now use FILTER to get all lines with the searchstring in them:
filter tData with ("*" & tSearchString & "*")
if tData = empty then
answer "No matching data!"
exit to top
end if
## Finally put found data into other datagrid
set the dgdata of grp "data display" to tData
...
You get the picture
Best
Klaus
Nice Klaus.
Many thanks.
Re: Searching a Datagrid
Posted: Fri Jan 24, 2014 10:35 pm
by Klaus
LC4iOS wrote:Nice Claus.
Klaus, with a
K!
Don't mess with a PIMP!

Re: Searching a Datagrid
Posted: Sat Mar 01, 2014 4:38 am
by keram
Hi Klaus with K,
Klaus wrote:if your datagrid is of type TABLE, you could do something like this:
Is this working
only for dg Tables or for dg Forms as well?
Nice photo of you...
or maybe photo on this page
http://newsletters.livecode.com/october ... etter3.php
is better ... is it you?
keram
Re: Searching a Datagrid
Posted: Sat Mar 01, 2014 10:02 am
by blairetabay
altamative131,
this work for me.
i am using a datagrid and a database to show the exact value is been search put this code in you button to search
it only work if you have a database.
Code: Select all
local Ldisplay
local Tdisplay, sea
put field "txt_keywords" into search
put "select id, lastName,givenName,middleName,age,sex from hos_tblpatientinfo where lastName LIKE '%" & search & "%'" into tabay
put revdatafromQuery(,,connID,tabay)into Tdisplay
set the dgText of group "dgGrid" to tDisplay
best
blaireTabay
Re: Searching a Datagrid
Posted: Sat Mar 01, 2014 12:17 pm
by Klaus
Hi Blaire,
yes, this is how one searches a database, but the original poster had been asking for something else!
Best
Klaus