Search in cells
FastGrid documentation
Search text in cell values or strings and focus or highlight them.
Search input and icon can be added to grid by
"Search" toolbar.
String that will be searched by
Search() function or on grid start.
It can be edited also by
Search default toolbar cell.
If it contains more words separated by space, they can be searched together or separately according to
SearchMulti.
Maximum separate words to search is 32.
If set SearchText and SearchAction contains ColorCells / ColorRows, the found cells / rows are colored automatically on repaint without call Search().
Action(s) done on
Search() or on paint or on grid start.
Search - if search is on. Must be set to do any search action.
Focus - focus cells, first forwards from start, next forwards from focus,
FocusNext - focus cells, forwards from focus,
FocusPrev - focus cells, backwards from focus,
ColorCells - color found cells, it searches the grid cells on
paint,
ColorRows - color rows containing found cells, it searches the grid rows on
paint,
SelectRows - select rows containing found cells,
FilterRows - filter (show only) rows containing found cells.
Cells - fills grid attribute
FoundCells as two dimensional array of found cells as [row.id][col.id].
Rows - fills grid attribute
FoundRows as array of found rows by their id.
Blocks - fills grid attribute
FoundBlocks as array of found row blocks by their Block attribute.
How the cell values are compared against
SearchText. The Word search searches the
SearchText string in every word of the cell value.
Number search: | 1 - Equal, 2 - Not equal, 3 - Less than, 4 - Less than or equal, 5 - Greater than, 6 - Greater than or equal |
String search: | 7 - Begins with, 8 - Does not begin with, 9 - Ends with, 10 - Does not end with, 11 - Contains, 12 - Does not contain |
Word search: | 13 - Any word begins with, 14 - No word begins with, 15 - Any word ends with, 16 - No word ends with, 17 - Any word equals to, 18 - No word equals to |
Cell value type to compare,
1 - raw not formatted value,
2 - value in edit format (default),
3 - value in display format (it also searches Number type as text).
How to compare
SearchText, if it contains more words space separated.
0 -
no - the cell is found if the cell value contains the whole text as is,
1 -
OR - the cell is found if the cell value contains any word from text,
2 -
cell AND - the cell is found if the cell value contains all words from text,
3 -
row AND - the row is found if every word from the text is found in some cell in the row, action "ColorCell" colors every the found cell, action "Focus" focuses every the found cell.
Various options to control the Search.
Index - if column with
Index=
1 can be searched and the row is found by its index, finds only this row on first search,
Repeat - does not show "Not found anything else" message and searches again,
FocusNext - if found cell cannot be focused, focuses next cell in the same row,
Wildcards - if
SearchReplaceOne and
SearchReplaceMore wildcards can be used for searching strings,
can slightly slow down the search,
ignores LocaleCompare,
ColorBlock - colors the whole row
Block when coloring rows by
SearchAction ColorRows.
EmptyOff - entering empty string to search cell will switch off the search.
NoGroup - will not search in columns used in group by.
Sync - sets
Search() method as always synchronous and never show progress message.
If the strings in search are compared as case sensitive.
If set, compares strings according to locale meaning.
0 | a<b<á | according to unicode |
1 | a<á<b | according to default locale |
2 | a==á<b | according to default locale |
"locale" | a<á<b | according to specified locale (e.g. "en-US" or "cs-CZ") |
"=locale" | a==á<b | according to specified locale (e.g. "=en-US" or "=cs-CZ") |
List of characters to ignore when comparing strings.
It can be set for example to " " (space) to ignore spaces (it means that for example "a b c" and "abc" strings are the same.
If starts by "-", it is ignored, but can be turned on in
SearchMenu.
It changes characters in comparing strings.
It is first character separated array of pair of characters to replace the first character by the second one when comparing strings.
For example "|y|i|Y|I|.|," - replaces 'y' by 'i', 'Y' by 'I' and '.' by ','
- it means that when comparing strings does not differ between letter 'y' and 'i', both cases and also does not differ between comma and point.
The first character must be one letter, but the second in fact can be any letter or string or even empty string, like "|a|xxx|b||c|ff".
For sorting and grouping it can be set only to row or column, for filtering it can be set also to filter cell and for generated List by *Rows / *Cols also to the cell with the List.
id of the column that will be focused when the row is found by search. If set, the search focused every found row only once.
If it starts by "-", it is not used for search, but still permits the option in search menu.
It can be set to more column ids comma separated, the first applicable column will be focused on find.
Comma separated list or array of row ids their cells will be searched. The rows not listed here are always searched except if they have set
NoSearch.
If the item starts by "
-", it is marked as not chosen and its cells are not searched.
If there is item named "
-", it represents all applicable rows as not chosen.
If there is item named "
*", it represents all applicable rows as chosen. For example "*,-Row3" chooses all rows except Row3.
Comma separated list or array of column ids their cells will be searched. The columns not listed here are always searched except if they have set
NoSearch.
If the item starts by "
-", it is marked as not chosen and is not exported as not chosen columns according to
Exporting.
If there is item named "
-", it represents all applicable columns as not chosen.
If there is item named "
*", it represents all applicable columns as chosen. For example "*,-Col1" chooses all columns except Col1.
Which rows are searched:
NoSearch - searches also in rows with
NoSearch =
1.
Collapsed - searches also in collapsed children.
Hidden - searches also in manually hidden rows.
Filtered - searches also in filtered rows. If set filter by
SearchAction&
64, this flag is always set.
Deleted - searches also in deleted rows.
Which columns are searched:
NoSearch - searches also in columns with
NoSearch =
1.
Collapsed - searches also in collapsed children.
Hidden - searches also in manually hidden columns.
Filtered - searches also in filtered columns and columns hidden by
HideGroupCols.
Deleted - searches also in deleted columns.
First character separated string or array as list of predefined searches displayed on top in search history list.
It can contain also special items "$SearchOff" to turn off search and "$SearchEmpty" to search empty string.
First character separated string or array as list of history searches displayed below
SearchList.
Regex string for separating words for
SearchCompare>=
13. For example "\\b" separates by all Regex word separators, "\\s" separates by white characters, "[,;\\s]" separates by white characters and comma and semicolon.
Wildcard character to specify one any character. Used when searching strings by operators
1,
2 and
7 -
12.
For example "a??d" finds "abcd" or "aa d", but not "abd" or "abced".
Wildcard character to specify none, one or more any characters. Used when searching strings by operators
1,
2 and
7 -
12.
For example "a*d" finds "abcd", "abd", "ad" or "abce d".
Maximum last searched items stored in search history. If set to 0, the history is not included in the Search cell popup list.
If searching is taking more than this time in milliseconds, progress message is shown during searching.
If set to
0, the search is always synchronous and cannot be cancelled during long process.
Comma separated string or array of items shown in Search menu. Set it to "" to not show the menu. It can contain "-" item as separator. Case sensitive. It can contain these keywords:
Focus (
SearchAction contains
Focus, focus cell search action choose),
ColorCells (
SearchAction contains
ColorCells, color cells search action),
ColorRows (
SearchAction contains
ColorRows, color rows search action),
SelectRows (
SearchAction contains
SelectRows, select rows search action),
FilterRows (
SearchAction contains
FilterRows, filter rows search action),
Compare (
SearchCompare, choose search compare method),
Type (
SearchType, choose search type 2 - edit format or 3 - display format),
Multi (
SearchMulti, choose how to search more words),
Case (
SearchCaseSensitive, turn on case sensitive search),
Locale (
SearchLocaleCompare, ignore diacritics, switches only between 0 / 2 values),
White (
SearchWhiteChars, ignore white space),
Index (
SearchOptions contains
Index, prefer row index search),
Repeat (
SearchOptions contains
Repeat, do not show message "Not found anything else"),
FocusCol (
SearchFocusCol, focus whole rows, sets the attribute with "-" prefix).
Group (
SearchOptions contains
NoGroup, do not search in columns used for group by),
Layout (changes
SearchRows and
SearchCols attributes, chooses items from popup submenu).
To hide disabled items in the menu set:
DefTools:{ Search:{ ListMenu:{ Script:{ HideDisabled:1 } } } } .
To show the menu in two columns set:
DefTools:{ Search:{ ListMenu:{ Script:{ Columns:2 } } } } .
If set, used instead of
AutoRemove to get rows / columns to search in when the part adds rows / columns automatically by
Auto.
If set, the row / column cannot be found by search. By default set to
1 in special rows / columns and to
0 in normal rows. Search never iterates toolbars.
If set, the cell is not iterated by search. It is read only if not set
FV&
32.
If set, it is used for Search instead of the cell value. Ignored if set
FV without &
16.
Toolbar string
D
= "Search"
Default toolbar to show
SearchText box and
Search icon.
Tool string
D
= "SearchText"
Default toolbar cell to show edit box with text to search. Changing the text run the search. It can show popup list with search history and search off item.
It is, but need not be, placed to
Search toolbar.
Tool string
D
= "Search"
Default toolbar cell to show Search icon to run the search and to show search options defined by
SearchMenu.
It is, but need not be, placed to
Search toolbar.
Grid method bool
Search
(any text = null, string action = null, int compare = null, int type = null, int multi = null, bits options = null, Col / string focuscol = null, Row row = null, Col col = null)
Runs given search action in grid. For
action containing only
ColorCells /
ColorRows just marks the grid for repaint.
If the parameter is null, it is read from appropriate grid attribute, if it is not null, its value is set to the appropriate grid attribute.
row and
col can be used instead of actually focused cell to search from this cell by action focus.
If
action is
true, does not change focused cell, if it is found.
If
action is
false, clears the search, remove the "Search" from actual
SearchAction.
API event bits
OnSearch
(Grid grid, Row row, Col col, any value, string type, string[] texts, number[] numbers, bits results)
Called on search in the cell value.
value is the cell value to search in.
type is cell type "Number", "String", "Date", "Html" - for Auto type it returs the type according to the cell value and format.
texts is parsed
SearchText to array of strings according to
SearchMulti, for
0 it contains one item.
numbers is parsed
SearchText to array of numbers according to
SearchMulti, for
0 it contains one item. If the word cannot be converted to number, the item is null.
results are temporary results for
SearchMulti =
3 in actual row. It has set apropriate bit for every found value in
texts /
numbers, &1 for found texts[0], &2 for texts[1], &4 for texts[2], ...
Return
null to ignore the event and do the default search or
0 as not found or
1 as found.
If found in the cell and
results is not null, return value containing bits of the found items from
texts /
numbers, similarly to bits in
results.
Grid method object[]
GetSearchHistory
( )
Returns menu items for actual search history and predefined searches.