Filtering in JavaScript TreeGrid
Filtering allows you to view specific or related records based on filter criteria. To enable filtering in the TreeGrid, set the allowFiltering to true. Filtering options can be configured through filterSettings.
To use filter, inject the Filter module in the treegrid.
- You can apply and clear filtering by using
filterByColumnandclearFilteringmethods.- To disable filtering for a particular column, set
columns.allowFilteringto false.
Filter hierarchy modes
TreeGrid provides support for a set of filtering modes with filterSettings.filterHierarchyMode property.
The below are the type of filter mode available in TreeGrid.
-
Parent : This is the default filter hierarchy mode in TreeGrid. The filtered records are displayed with its parent records, if the filtered records not have any parent record then the filtered records only displayed.
-
Child : The filtered records are displayed with its child record, if the filtered records not have any child record then the filtered records only displayed.
-
Both : The filtered records are displayed with its both parent and child record, if the filtered records not have any parent and child record then the filtered records only displayed.
-
None : The filtered records are only displayed.
Initial filter
To apply the filter at initial rendering, set the filter predicate object in
filterSettings.columns.
Filter operators
The filter operator for a column can be defined in the filterSettings.columns.operator property.
The available operators and its supported data types are:
| Operator | Description | Supported Types |
|---|---|---|
| startswith | Checks whether the value begins with the specified value. | String |
| endswith | Checks whether the value ends with the specified value. | String |
| contains | Checks whether the value contains the specified value. | String |
| equal | Checks whether the value is equal to the specified value. | String | Number | Boolean | Date |
| notequal | Checks for values not equal to the specified value. | String | Number | Boolean | Date |
| greaterthan | Checks whether the value is greater than the specified value. | Number | Date |
| greaterthanorequal | Checks whether a value is greater than or equal to the specified value. | Number | Date |
| lessthan | Checks whether the value is less than the specified value. | Number | Date |
| lessthanorequal | Checks whether the value is less than or equal to the specified value. | Number | Date |
By default, the
filterSettings.columns.operatorvalue isequal.
Diacritics
By default, treegrid ignores diacritic characters while filtering. To include diacritic characters, set the filterSettings.ignoreAccent as true.
In the following sample, type aero in Name column to filter diacritic characters.
You can refer to our
JavaScript Tree Gridfeature tour page for its groundbreaking feature representations. You can also explore our JavaScript Tree Grid exampleJavaScript Tree Grid exampleto knows how to present and manipulate data.