Page 1 of 1

Searching all cells in a MD Datatable

Posted: Thu Sep 20, 2018 4:50 pm
by soa
I want to search all cells in a material data table for a string with this sort of logic

For each Row in List
found = false
for each Col in Row
if item value contains 'Search string'
found = true leave
endif
Row.Visible = found
end for
end for

Can this be done?

I can see a columns collection but not a rows collection

Re: Searching all cells in a MD Datatable

Posted: Fri Sep 21, 2018 1:35 am
by TomC
The following will check the value of a search edit field, against all cells in a data table. You will have to handle the processing to add/remove a found row, but it should not be difficult to do from here.

Code: Select all

Evtroutine Handling(#Search.Changed)
Define_Com Class(#xDemoUnicode128) Name(#Cell)

Selectlist Named(#List)
For Each(#column) In(#List.Columns)

If (#Column *Is #Prim_list.String)
#Cell := (#Column *As #Prim_list.String).CurrentItem.Value
Endif

If (#Column *Is #Prim_list.Number)
#Cell := (#Column *As #Prim_list.Number).CurrentItem.Value.AsString
Endif

Continue If(*Not #Cell.UpperCase.Contains( #Search.Value.UpperCase ))

* Handle the record being found
#SYS_WEB.Alert Caption(#Cell)

Endfor
Endselect

Endroutine

Re: Searching all cells in a MD Datatable

Posted: Fri Sep 21, 2018 1:39 am
by TomC
Even better, check out the example Web Page in the IDE:

xDemoWebHighlightListCells

This is where I originally got the syntax.

Re: Searching all cells in a MD Datatable

Posted: Fri Sep 21, 2018 8:31 am
by soa
Thanks.Great response i'll give that a go.