Omnis Technical Note TNNO0008

Using $filter on a list

For Omnis Studio
By Rod Cooper

You can use the $filter method to filter the contents of a list. Once the list data is built you must set the list to be a smart list. The following methods can be used to filter or unfilter a list:

; in the construct of the window
Do iList.$define(iCol1,iCol2,iCol3)
Do iList.$add(10,20,30)
; etc
Do iList.$smartlist.$assign(kTrue)

; to filter a list
Do iList.$filter(iCol1=iCol1FilterVal) ;; iCol1FilterVal is set in the window
or to clear the current filter
Do iList.$unfilter()

Download a library from GitHub: https://github.com/OmnisStudio/Omnis-FilterList (for Studio 8.1.2 or above)
(or an archive: filter.zip for Studio 4 or above, may require conversion)