Data Grid form search functionality (filtering)
Posted: Thu Feb 23, 2023 2:30 pm
Hello All,
I have a Data Grid form displaying a very long list (single-word and multi-word text descriptions).
There is a Field on the card, which is used to enter search terms in order to filter the items in the Data Grid form down to a manageable length in oder to make finding items easier. I have implemented basic search functionality using this field script:
global gDataGridArray_A
on textChanged
local tFilteredArray, tFilter
put text of me into tFilter
if tFilter is not empty then
filter elements of gDataGridArray_A where each["TXT"] contains tFilter into tFilteredArray
set the dgData of group "DataGrid_A" to tFilteredArray
else
set the dgData of group "DataGrid_A" to gDataGridArray_A
end if
end textChanged
This works well and only displays items in the Data Grid containing the text entered in the field. For example, if “ard” is entered, only items containing “ard” will be displayed in the Data Grid: "a block of lard", "piece of chard", etc.
Question 1: Is this a good approach in terms of using ‘filter’ and setting the dgData in this way?
I now need to enhance the search functionality so that it will search for multiple part matches of strings. For example, if an item in the list is: “pastel colours and stripes”, I want to be able to type “pas our” to locate it. Or “ast olor ice”. Or “rs tel pes”
Question 2: Any thoughts on how to approach that?
Thanks in advance (for answers or suggestions either question)
Mark
I have a Data Grid form displaying a very long list (single-word and multi-word text descriptions).
There is a Field on the card, which is used to enter search terms in order to filter the items in the Data Grid form down to a manageable length in oder to make finding items easier. I have implemented basic search functionality using this field script:
global gDataGridArray_A
on textChanged
local tFilteredArray, tFilter
put text of me into tFilter
if tFilter is not empty then
filter elements of gDataGridArray_A where each["TXT"] contains tFilter into tFilteredArray
set the dgData of group "DataGrid_A" to tFilteredArray
else
set the dgData of group "DataGrid_A" to gDataGridArray_A
end if
end textChanged
This works well and only displays items in the Data Grid containing the text entered in the field. For example, if “ard” is entered, only items containing “ard” will be displayed in the Data Grid: "a block of lard", "piece of chard", etc.
Question 1: Is this a good approach in terms of using ‘filter’ and setting the dgData in this way?
I now need to enhance the search functionality so that it will search for multiple part matches of strings. For example, if an item in the list is: “pastel colours and stripes”, I want to be able to type “pas our” to locate it. Or “ast olor ice”. Or “rs tel pes”
Question 2: Any thoughts on how to approach that?
Thanks in advance (for answers or suggestions either question)
Mark