Filtering allows users to view a subset of data based on criteria. There are three ways for a user to filter:
setGlobalFilter action from the Data Grid Context.Active Actions
Once a filter is active, the user can:
You must opt-in to column filtering by setting the features.filter prop to true or passing in a custom filter function. Doing so will display the filter option in the column menu.
Multi-column filtering is enabled by default. The user simply selects another column to filter in addition to any other column that is actively filtered.
You can globally filter the Grid by utilizing the setGlobalFilter action in any slot component you provide.
In this example, we create a custom Toolbar that filters the grid globally on input.
A comparator determines how two cell values should be filtered. The default comparator uses the vanilla JavaScript basic comparison from the Operator provided.
To provide a custom comparator, you can pass a function as the features.filter option.
The snippet below is the same comparator we are using for all the demos on this page.
The Data Grid provides an OPERATORS constant which is used to ensure consistency across any filter-based approach you may use.
The filter feature accepts either a boolean or a custom filter function that provides the following arguments:
| Params | Type | Description |
|---|---|---|
row | TData | The row of the grid comparing the filter. |
columnId | string | The columnId the filter is applied to. |
filterValue | unknown | The value provided to the filter. |