filters data items in a component
filter(rule?: function | object, config?: object): string;
Parameters:rule: function | object
- the filtering criteria
by: string | number
- mandatory, the id of a data fieldmatch: string
- mandatory, a pattern to matchcompare: function
- optional, a function for extended filtering that takes three parameters:
value
- the value to comparematch
- a pattern to matchitem
- a data item the values of which should be comparedconfig: object
- optional, defines the parameters of filtering. It may contain the following properties:
id: string
- optional, the id of the filteradd: boolean
- optional, defines whether each next filtering will be applied to the already filtered data (true), or to the initial data (false, default)permanent: boolean
- optional, true to make the current filter permanent. It will be applied even if the next filtering doesn't have the add:true
property in its configuration object. Such a filter can be removed just with the resetFilter() methodid: string
- the id of the filterExample
// filtering data by a function
grid.data.filter(function (item) {
return item.a > 0 && item.b !== "Apple";
});
// or
grid.data.filter(function (item) {
return item.a > 0 && item.b !== "Apple";
}, {
add: true,
});
// filtering data by the column
grid.data.filter({
by: "a",
match: "Orange",
compare: function (value, match, item) {
if (item.a !== "Some") {
return val === "New";
}
return false;
}
}, {
add: true,
});
Related sample: Data. Filter
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4