Searching all cells in a MD Datatable

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
soa
Posts: 275
Joined: Mon Dec 07, 2015 3:15 pm

Searching all cells in a MD Datatable

Post by soa » Thu Sep 20, 2018 4:50 pm

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

TomC
Posts: 10
Joined: Thu Mar 10, 2016 10:01 am

Re: Searching all cells in a MD Datatable

Post by TomC » Fri Sep 21, 2018 1:35 am

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

TomC
Posts: 10
Joined: Thu Mar 10, 2016 10:01 am

Re: Searching all cells in a MD Datatable

Post by TomC » Fri Sep 21, 2018 1:39 am

Even better, check out the example Web Page in the IDE:

xDemoWebHighlightListCells

This is where I originally got the syntax.

soa
Posts: 275
Joined: Mon Dec 07, 2015 3:15 pm

Re: Searching all cells in a MD Datatable

Post by soa » Fri Sep 21, 2018 8:31 am

Thanks.Great response i'll give that a go.

Post Reply