apply-filter
Description
Fires when a filter is applied
Usage
"apply-filter": ({
rule: {}
}) => boolean | void;
Parameters
The callback of the action takes an object with the following parameters:
rule
- any filter configuration object with such parameters as below:field
- (required) the field id to which filter will be appliedfilter
- (required) filter type:- for text values: equal, notEqual, contains, notContains, beginsWith, notBeginsWith, endsWith, notEndsWith
- for numeric values: greater: less, greaterOrEqual, lessOrEqual, equal, notEqual, contains, notContains
- for date types: greater, less, greaterOrEqual, lessOrEqual, equal, notEqual, between, notBetween
value
- (required) the value to filter byincludes
- (required) an array of values to be displayed from those that are already filtered; available for text and date values
info
For handling the inner events you can use the Event Bus methods
Example
const table = new pivot.Pivot("#root", {
fields,
data,
config: {
rows: ["studio", "genre"],
columns: [],
values: [
{
field: "title",
method: "count"
},
{
field: "score",
method: "max"
}
]
}
});
//output to console the label of the field to which filter was applied
table.api.on("apply-filter", (ev) => {
console.log("The field to which filter was applied:", ev.rule.field);
});
Related articles: api.on()