useFilters
All of Kyber's Filters are compatible with the useFilters plugin.
Filters are configured through the column object. When the useFilters plugin is used a column can define a filter
property with a type
that will create a filter of that type. For example, the following column array would bind a NumberFilter to the salary column. The type property is unique to the filter object and any other properties will be passed as props to the filter component.
Note: This demo is statefully managed for the purpose of showing how the plugin can be used statefully. The options columnState
and onFilterChange
are not required.
const columns = [
{
key: 'salary',
label: 'Salary',
filter: { type: 'Number', operator: 'gte' },
},
];
Plugin
PluginProperties
Type: Object
Properties
filterMethod
A function that can be used to overwrite the default filtering of the plugin.columnState
Object? The initial or statefully managed state of all filters. See the filter type of the column for properties that can be provided.onFilterChange
A callback that will be called whenever a filter is applied.
useFilters
Create a plugin hook that enables DataTable filtering and adds the filter component to the table bar.
Parameters
props
(optional, default{}
)
Returns Plugin
filterMethod
The filter method callback can be used to manually filter data based on applied filter values.
Type: Function
Parameters
filterValues
Object An object representing all the applied filters. This contains key value pairs keyed by column key.
onFilterChange
A callback that will be called whenever a filter is applied.
Type: Function