Datagrid Search

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
Gautami
Posts: 35
Joined: Tue Aug 06, 2013 5:25 am

Datagrid Search

Post by Gautami » Wed Aug 28, 2013 1:13 pm

Hi everyone,

I have a datagrid form with each row having 3 text fields.
It is taking in data from a sqlite file.
I also have a search box.
I would like to type a query into the search box and have it highlight every
instance it appears in the datagrid. I also want to count the number of times if occurs.

The find command works for only the data that is visible on the card. When i scroll down, I have to re enter text in the search box to find the next instance of the word I am looking for. Is there any other way I can achieve my objective?

Thank you.
Regards,
Gautami

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Datagrid Search

Post by Simon » Wed Aug 28, 2013 7:29 pm

Hi Gautami,
This isn't exactly what you asked for but it may help:
http://quartam.blogspot.com/2010/07/dat ... ample.html

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Gautami
Posts: 35
Joined: Tue Aug 06, 2013 5:25 am

Re: Datagrid Search

Post by Gautami » Fri Aug 30, 2013 6:25 pm

Hi Simon,
Thank you!
I will look into this :)

Thanks for helping.

G

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: Datagrid Search

Post by dunbarx » Fri Aug 30, 2013 7:13 pm

You can always put the dgText of your DG into a variable, and do a search for your text with something like

Code: Select all

function revFullFind tText,tFind,exactly --RETURNS LINE NUMBER & "," & WORD NUMBER
   put 0 into counter
   switch exactly
      case "true"
      case empty
         repeat for each line tline in tText
            add 1 to counter
            if tFind = tline then
               put counter & return after tResult
            end if
         end repeat
         break
      case "false"
         repeat for each line tline in tText
            add 1 to counter
            if tFind is in tline then
               repeat with y = 1 to the number of words in tLine
                  if word y of tLine = tFind then put y & "," after temp
               end repeat
               delete last char of temp
               put counter & "," & temp & return after tResult
               put "" into temp
            end if
         end repeat
         break
   end switch
   return tResult
end revFullFind
This will give a list of the line numbers that either contain your text or equal it. You can then go back to the DG and set the DGHilitedLiines.

Craig Newman

Post Reply