Page 1 of 1

Search in Data Grid Form

Posted: Tue Mar 04, 2014 3:27 am
by keram
Hello,

I'd like to do a search in a data grid form but exclude the hilite state of checkboxes.
Here are the steps:
put the dgText of grp "DataGrid 1" into tData
then
filter tData with ("*" & tSearchString & "*")

but in the tData there will be "true" or "false" for the hilite state of checkboxes.
If I want to search the text lines for words like true or false etc. then the lines that have the checkbox hilites as true or false will also be found and displayed.

How can I eliminate in a simplest way the checkbox hilites values from the filter?
Attached is the stack as an example.

Thanks in advance.

keram

Re: Search in Data Grid Form

Posted: Tue Mar 04, 2014 12:14 pm
by Klaus
Hi keram,

OK, first use the FILTER WITH command for a rough check.
Then you will need to loop through all lines and all items of the lines that you want to check.
Means leave out the column(s) with the hilite values.

Know what I mean?
No quick way :D


Best

Klaus

Re: Search in Data Grid Form

Posted: Tue Mar 04, 2014 4:36 pm
by keram
Thanks Klaus,

If I understood correctly this would be the solution:

Code: Select all

on mouseUp
   local tSearchString,Counter = "0", DataArray
   set itemDel to tab
   
   ask "Search for what word or string of words?" with "tellus" titled "Search"
   if it = empty then exit to top
   put it into tSearchString
   
   put the dgText of grp "DataGrid 1" into tData
   
   filter  tData with ("*" & tSearchString & "*") 
   
   repeat for each line i in tData
      filter item 3 of i  with ("*" & tSearchString & "*")  --  I want to search only in item 3 of each line 
   end repeat
   
   if tData = empty then
      answer "No matching data!"
      exit to top
   end if
    
   lock screen
   repeat for each line i in tData
      add 1 to Counter
      put item 4 of i into DataArray[Counter]["Num"]  --line 1 number of dgform
      put item 1 of i into DataArray[Counter]["BtnCheck"]  --line 1 checkbox of dgform
      put item 2 of i into DataArray[Counter]["Cat"]  --line 1 cat of dgform
      put item 3 of i into DataArray[Counter]["Label"]  --line 1 label of dgform
   end repeat
   
   
   set the dgData of grp "DataGrid 1" to DataArray  --populate dgform
   set the dgVScroll of grp "DataGrid 1" to "0"  --top
   send "RefreshList" to grp "DataGrid 1"
   
end mouseUp
   
this is what I added:
filter tData with ("*" & tSearchString & "*")

repeat for each line i in tData
filter item 3 of i with ("*" & tSearchString & "*") -- I want to search only in item 3 of each line
end repeat

but still when I search for false or true, the search is not ignoring the columns with hilite values.

keram

Re: Search in Data Grid Form

Posted: Tue Mar 04, 2014 5:04 pm
by Klaus
Hi Keram,

you cannot filter ITEMS in a line unfortunately!

I was thinking of something like this:

Code: Select all

on mouseUp
  local tSearchString,Counter = "0", DataArray
  set itemDel to tab
  ask "Search for what word or string of words?" with "tellus" titled "Search"
  if it = empty then
    exit to top
  end if
  put it into tSearchString
  put the dgText of grp "DataGrid 1" into tData
  filter  tData with ("*" & tSearchString & "*")
  
  ## No need to continue if the rough check already fails!
   if tData = empty then
    answer "No matching data!"
    exit to top
  end if
  
  repeat for each line i in tData
    if item 3 of i contains tSearchString then
      put i & CR after tNewData
    end if
  end repeat
  delete char -1 of tNewData
     
  ## Nothing found
  if tNewData = empty then
    answer "No matching data!"
    exit to top
  end if
     
  ## Since your datagrid ia obviously a TABLE you can simply: 
  set the dgTEXT of grp "DataGrid 1" to tNewData  --populate dgform
  set the dgVScroll of grp "DataGrid 1" to "0"  --top
  send "RefreshList" to grp "DataGrid 1"    
end mouseUp
Best

Klaus

Re: Search in Data Grid Form

Posted: Tue Mar 04, 2014 5:47 pm
by keram
Hi Klaus,

It works OK now.
This is a dg FORM so the last few lines I have to keep as they were before:
lock screen
repeat for each line i in tNewData
add 1 to Counter
put item 4 of i into DataArray[Counter]["Num"] --line 1 number of dgform
put item 1 of i into DataArray[Counter]["BtnCheck"] --line 1 checkbox of dgform
put item 2 of i into DataArray[Counter]["Cat"] --line 1 cat of dgform
put item 3 of i into DataArray[Counter]["Label"] --line 1 label of dgform
end repeat

set the dgData of grp "DataGrid 1" to DataArray --populate dgform


Thanks again :)

keram

Re: Search in Data Grid Form

Posted: Tue Mar 04, 2014 5:50 pm
by Klaus
Hi Keram,
keram wrote:This is a dg FORM
ah, OK, I guessed TABLE from your first lines:
...
put the dgText of grp "DataGrid 1" into tData
filter tData with ("*" & tSearchString & "*")
...
:D

Best

Klaus