Filtering rows / columns
FastGrid documentation
The filters are set in row / column with
Kind = "
Filter", usually set by
D = "
Filter".
Or custom filters are set by
SetFilter API method.
Row, Col string
D
= "Filter"
Default row or column to show cell filters. Every cell can have set its filter operator in
Filter object.
It is expected to place only in fixed sections (rows or columns) with maximally 30 items.
Cell, Tool string
D
= "FilterAction"
Default cell or toolbar cell to show filter icon to switch among OFF, OR and AND operators between filters.
If placed to
Filter row or column, it controls only this filter and changes its
FilterAction attribute.
If placed anywhere else, it controls all filters and changes grid
FilterAction attribute among 0,1,2 values.
Set
BoolMin =
0 to switch only between OFF and AND.
Set
BoolMax =
0 to switch only between OFF and OR.
Tool string
D
= "FilterTree"
Default toolbar cell to combo box to choose value for
FilterTree attribute from popup list.
Row, Col string
FilterPart
["DefRowPart" / "DefColPart" / ""] GetAttr SetAttr
Comma separated string or array of part ids that will be filtered by this
Filter row.
The item can be set also to
"DefRowPart" as
DefRowPart or
"DefColPart" as
DefColPart.
Default value is
"DefRowPart" in
D="Filter" row,
"DefColPart" in
D = "Filter" column and none in all other rows and columns.
Defines filter operators for individual
Filter cells.
The Filter cells values are defined in standard V attribute.
Defined as an object with values assigned to column or row ids. For example:
{ id:1, Filter:{ C:3, D:11 }, V:{ C:100, D:"XXX" } }
For row it supports also
Array and
String definition by
AIndex like
A attribute, but these definitions have slower processing and are used rarely.
It can be one of
predefined filters:
Off: | 0 - Off |
Number filter: | 1 - Equal, 2 - Not equal, 3 - Less than, 4 - Less than or equal, 5 - Greater than, 6 - Greater than or equal |
String filter: | 7 - Begins with, 8 - Does not begin with, 9 - Ends with, 10 - Does not end with, 11 - Contains, 12 - Does not contain |
Range filter: | 13 - Equal all, 14 - Not equal all |
If set to
Filter cell, the cell does not show filter operator and does not provide filtering.
This cell is still editable, set
NoEdit:
1 to not edit it.
There is still reserved place for the Filter icon, to hide it set
LeftIcons :
"".
If set, automatically sets given filter value after change of the
Filter cell value if it has not set
Filter yet.
Default value is
1 for types Number, Date and Bool and
11 for types String, Html and Auto.
When this value is entered to the
Filter cell and it has set
Filter, the
Filter for the cell is cleared.
For Bool type it slightly differs: after which Bool value in
BoolCycle clears the
Filter for the cell.
Default value is
0 for Bool type and
"" for other types.
If set, clears the filter cell value when chosen the
0 (off) filter operator.
Active custom filters defined for given row or column part.
Defined for example as:
Body:{Filter:{MyFilter:"A>10 || B<20"}}
The filter string is the filter JavaScript formula in string. It has the same syntax as
JavaScript Formula.
If filters rows, it can use variables
Grid,
Row and column ids as the Row cell values, e.g.
F1:"B>5&&C!='AB'").
If filters columns, it can use variables
Grid and
Col. The column cells can be read by "Grid.Get('xxx',Col)".
Grid method bool
HasFilter
(string part = null, bits type = 13)
If the
part has some filter set. If the
part is null, checks all parts in grid.
type controls which filter is checked:
1., 2. bit &
3 =
1 - has any active filter in
Filter row / column,
2 - has any filter set in
Filter row / column (even if the
FilterAction is
0).
3. bit &
4 =
4 - has any custom filter set by
SetFilter method.
4. bit &
8 =
8 - has set
Search filter.
Grid method any
GetFilter
(string part = "Body", int type = 1)
Returns filters set in the
part.
type controls which filters to return:
1 - all active filters set by
Filter rows / columns.
2 - all set filters set by
Filter rows / columns (even if the
FilterAction is
0).
Returns two dimensional array as [[row1,col1,operator1,value1],[row2,col2,operator2,value2],...].
4 - returns all custom filters in object as [name] = filter_string.
If the filter was set by
FilterRange, returns the created filter that was sent to
SetFilter method.
8 - returns Search filter function.
Grid method void
ChangeFilter
(any[] cols = null, string[] values = null, string[] operators = null, Row row = null, int clear = 2)
Changes cell values and operators in given
Filter row.
If
row is null, modifies the first
Filter row in grid.
cols is comma separated string or array of column ids or array of column objects to set their values and operators.
values is comma separated string or array of values to set to the
cols cells.
operators is comma separated string or array of filter operator numbers to set to the
cols cells in
Filter.
row can be also column filter object, therefore
cols will be row ids.
If set
clear, clears all other
Filter operators in the
row.
For
clear =
2 (default) clears also the other values if set
ClearFilterOff and for
3 clears the other values always.
Grid method void
ClearFilters
(string part = null)
Clears all filters set for the
part. If the
part is null, clears all filters in grid.
Clears filters set in
Filter row / column.
Grid method void
SetFilter
(string name, string filter = null, string part = "Body")
Sets custom filter to given
part - it can contain more part ids comma separated string or as an array.
name is the filter identification for later changes.
filter is the filter JavaScript formula in string. It has the same syntax as
JavaScript Formula.
If filters rows, it can use variables
Grid,
Row and column ids as the Row cell values, e.g.
grid.SetFilter("F1","B>5&&C!='AB'").
If filters columns, it can use variables
Grid and
Col. The column cells can be read by "Grid.Get('xxx',Col)".
If the
filter is null, it removes the filter
name.
Grid method void
FilterRange
(string col, string filter = null, string type = null, string part = "Body")
Sets custom filter to given
part - it can contain more part ids comma separated string or as an array.
col is column or row object that will be filtered.
filter is range value to filter the
col by, e.g. "3~5;8;12~15" or "1/1/2000~1/1/2001" or "one;two;three".
If the
filter is null, it removes the filter
name (or #col).
type is value Type, it can be "String", "Date" or "Number". If not set, it is read from
col.Type or is estimated from the
filter.
name is the filter identification for later changes, if not set, the "#"+
col.id is used.
Grid method void
ReFilter
(string part = null)
Filters given
part again without changing the settings.
part can be comma separated string or array of part ids.
If
part is not set, filters all parts that has set custom filter, Search or are referred by some
Filter row / column.
It can be run asynchrounsly when applied SyncRows.
Grid method bool
ShowFilterMenu
(Row row, Col col)
Shows filter menu with filter operators for given cell. Returns true for success or false on fail.
Actions
ShowFilterMenu
(int target = 0)
OnClickFilter
Shows filter menu with filter operators for actual or focused cell.
API event void
OnFilterChanged
(Grid grid, Row / Col / string filter)
Called after given
filter has been changed, but before re-filtering the grid.
filter can be row or column
Filter object or name of custom filter or "#Search" for search.
API event bool
OnFilter
(Grid grid, string part)
Called before filtering given
part. Return true to cancel the filter.
It is
not possible to change filter settings here.
API event void
OnFiltered
(Grid grid, string part)
Called after filtering given
part is done.
API event bool
OnTestFilter
(Grid grid, Row / Col item, bool ok)
Called during filtering for every row or column
item being filtered.
ok is the filter result for the
item, (
1 = show,
0 = hide).
Return
1 or
0 as new
ok value for the
item or null to continue without change.
Filter settings
If set, the row is excluded from filter when filtering by this cell.
0 - the filter is processed normally.
1 - the cell always fulfills the filter condition.
2 - the cell never fulfills the filter condition, the row can be shown by
FilterTree.
It is not tested in custom filters set by SetFilter, there must be tested explicitly.
If set, the column is excluded from filter when filtering by this cell.
0 - the filter is processed normally.
1 - the cell always fulfills the filter condition.
2 - the cell never fulfills the filter condition, the column can be shown by
FilterTree.
It is not tested in custom filters set by SetFilter, there must be tested explicitly.
Value used instead of cell value for filtering and searching.
List of ids of default rows or default columns. Only rows / column that's
D is listed here are affected by this Filter cell. Other rows / column always fulfill the filter condition.
FilterD is tested after
NoFilterRow /
NoFilterCol.
List of ids of default rows or default columns. It contains available items for the
FilterD.
It can be first characted separated string or array of strings or array of menu item objects with
Value and
Text attributes.
This list is added into the
Filter operators menu to choose the values for
FilterD.
The added list is controlled by default menu "FilterDList".
How to filter rows (columns) in
Block by this Filter cell.
0 -
Ignore blocks. Shows only rows (columns) that fulfill the condition, regardless on their
Block.
1 -
First in block. The row (column) fulfills condition in this cell if the first row (column) in its
Block that has
not set
NoFilterRow /
NoFilterCol and has acceptable
D for
FilterD fulfills the condition.
If the filtering by this
Filter row / column is permitted and how the individual cells filters are merged together.
0 -
off - the filter is not applied
1 -
AND - all filters must be fulfilled to show the row / column
2 -
OR - at least one filter must be fulfilled to show the row / column.
If the filtering by
Filter rows / columns and
Search is permitted and how the individual rows / columns filters are merged together.
0 -
off - no filter / search is applied
1 -
AND (rows/cols) +
AND (cells) - all filters must be fulfilled to show the row / column
2 -
OR (rows/cols) +
OR (cells) - at least one filter must be fulfilled to show the row / column.
3 -
OR (rows/cols) +
AND (cells) - at least one Filter / Search, but all its cell filters must be fulfilled to show the row / column.
4 -
AND (rows/cols) +
OR (cells) - all Filter / Search filters, but at least one their cell filter must be fulfilled to show the row / column
The application for
Filter cells is done only if their
FilterAction is not set.
If the filtering by custom filters is permitted and how they are merged together and with
Filter rows / columns and
Search.
0 - off - ignores all custom filters.
1 -
AND
2 -
OR
3 - uses
FilterAction (0 = off, 1/4 = AND, 2/3 = OR).
4 - uses
FilterAction (0 = off, 1/2/34 =
AND).
5 - uses
FilterAction (0 = off, 1/2/34 =
OR).
How to filter rows (columns) in tree.
0 -
Show only found. Shows only rows that fulfill the condition, regardless on tree.
1 -
Show only found, with all children. If some row fulfills the condition, all its children are shown too and not iterated.
2 -
Show all found. If some row fulfills the condition, all its parents are shown too.
3 -
Show all found, with all children. If some row fulfills the condition, all its parents and all its children are shown too. The children are not iterated.
4 -
Hide all not found. If some row does not fulfill the condition, it hides all its children and does not iterate them.
5 -
Hide all not found, with all children. If row does not fulfill the condition, it hides all its children. If row fulfills the condition, it shows all its children. The children are not iterated.
If colors or marks the filtered rows / columns in
FilterTree.
1. bit &
1 - if set to
1, colors or marks rows / columns that fulfill the filter - marks only rows / columns for that the filter is applied.
2. bit &
2 - if set to
2, colors or marks also all other rows / columns that fulfill the filter, iterates also the children for
FilterTree = 1, 3, 5.
The items are colored or marked according to
MarkRows /
MarkCols.
Wildcard character to specify one any character. Used when filtering 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 filtering strings by operators
1,
2 and
7 -
12.
For example "a*d" finds "abcd", "abd", "ad" or "abce d".
If the empty cells will be ignored by some filter operators. Bit array.
The setting is
not applied when comparing / searching empty string.
1. bit &1 | Never shows empty numbers for operators <, <=, >, >=. |
2. bit &2 | Never shows empty strings for operators <, <=, >, >=. |
3. bit &4 | Never shows empty strings for operators not contain / not begin / not end |
4. bit &8 | Never shows empty numbers for operator not equal |
5. bit &16 | Never shows empty strings for operator not equal |
If set to negative value, it is not used, but can be turned on by
FilterMenu.
Comma separated string or array of items shown in Filter menu. Set it to "" to not show the menu. It can contain "-" item as separator. Case sensitive. It can contain these keywords:
Clear action item, clears all filters,
Locale (
FilterLocaleCompare, ignore diacritics, switches only between 0 / 2 values),
White (
FilterWhiteChars, ignore white space),
Case (
FilterCaseSensitive, turn on case sensitive search),
Tree (
FilterTree, controls filtering in tree),
Color (
ColorFilter, colors the found rows),
Empty (
FilterIgnoreEmpty, restricts showing empty values by particular filter operators),
ClearOff (
ClearFilterOff, clears the filter cell value when choosed filter off operator).
1 -
filtering single values if listed or are in range in the filter.
Set it to
1 to permit the
Filter to contain more values or value ranges.
The filtered cells values must be single values and
not ranges.
The
1 (Equal) /
2 (Not equal) filter operators compare the filtered value with all values in the filter and in numbers and dates also in the filter ranges.
The
2 -
6 compare filter operators for filtered ranges just compare strings as they are, so they have not much sense here.
The
7 -
12 string filter operators search also all the listed filter values and the filter is fulfilled if any of the listed value is found.
2 -
filtering range values if contain one or all listed values in the filter.
Set it to
2 to permit filtering
range values.
The filter value and filtered values can contain more values, but not value ranges. (e.g. "one;three;five" but not "1~5;7~8")
The
1 (Equal) - The filter is fulfilled if the value contains one or more values from filter list.
The
2 (Not equal) - The filter is fulfilled if the value does not contain any value from filter list.
The
13 (Equal all) - The filter is fulfilled if the value contains all values from filter list.
The
14 (Not equal all) - The filter is fulfilled if the value does not contain at least one value from filter list.
If set to filter cell, filters in this column (row) by raw cell unformatted value and ignores
List.
Menu displayed on click to the
Filter operator icon.
It can be comma separated string or array of
Filter operator numbers
0 -
14, to specify the shown operators and their order.
Or it can be full
Menu object definition to display it instead of standard filter operators menu.
Grid method void
SetFilterAction
(int action, object item = null, bool clear = 0)
Sets
FilterAction of the grid (
item = null) or part (
item = string) or row / column (
item = object) to
action and refilters grid.
If set
clear and
item is row or column, it sets row/column
FilterAction to null if it is the same as global
FilterAction.
It can be run asynchrounsly when applied SyncRows.
Grid method void
HasFilterAction
( )
Returns true, if there is only one Filter row or column and it has set
FilterAction. Used to distinguish if the toolbar FilterAction should have two or three states.
Comparing strings
If the strings in filter are compared as case sensitive.
Used only if the row, column, cell has not set the CaseSensitive attribute.
If the strings are compared as case sensitive.
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.
If set, compares strings in filter according to locale meaning.
Used only if the row, column, cell has not set the LocaleCompare attribute.
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") |
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") |
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.
List of characters to ignore when comparing strings for filter.
Used only if the row, column, cell has not set the WhiteChars attribute.
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
FilterMenu.
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.
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.
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.
If set, removes all HTML code when comparing strings during sorting, grouping and filtering.
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.