filter([filter])
Class: Table.
Description:
Sets row filter expression which can be a combination of conditions similar to if() condition in JavaScript.
Setting the filter hides rows that don't match specified filter criteria. When filter is set to "", filter gets cleared and all rows become visible again.
- Filter format is in the form of IF condition:
"column(index) operator comparison_value". - Note that a column must be specified on the left side of the condition and comparison value on the right side.
- Conditions can be combined using AND "&&", OR "||", and parenthesis "( )".
- Condition in parenthesis can be negated by "!" before parenthesis.
- Valid operators are:
! ( ) < == != > && || regex. comparison_valuecan be anumber,stringvalue,stringregular expression, orboolean.
See examples below.
Parameters:
| Name | Type | Description |
|---|---|---|
|
|
string |
Filter to use to display only rows that meet the specified conditions. Default is "" (no filter). |
Returns:
Returns this Table when setting filter, otherwise returns current filter.
Type: Table | string
Examples:
// Using case insensitive regular expression
table.filter(`column(1) regex "(?i)^Jim.*"`);
// Filtering by numeric value
table.filter("column(1) < 50");
// Filtering by date
table.filter(`column(3) > "2023-04-01 00:00:00" && column(3) < "2024-05-30 00:00:00"`);
// Filtering by a boolean for checkbox
table.filter("column(4) != false");
