filters data items in a component
rule | function|object | the filtering criteria |
config | object | optional, defines the parameters of filtering |
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
});
// or
grid.data.filter({
by: "a",
match: "Orange",
compare: function (value, match, item) {
if (item.a !== "Some") {
return val === "New";
}
return false;
}, {
add: true
});
Calling the filter() method without parameters reverts the component to the initial state:
grid.data.filter();
The rule parameter:
grid.data.filter(function (item) {
return item.a > 0 && item.b !== "Apple";
});
by | (string) mandatory, the id of a data field (the column of Grid) |
match | (string) mandatory, a pattern to match |
compare | (function) optional, a function for extended filtering that takes three parameters:
|
For example:
grid.data.filter({
by: "a",
match: "Orange",
compare: function (value, match, item) {
if (item.a !== "Some") {
return val === "New";
}
return false;
});
The config parameter may contain two properties:
add | (boolean) defines whether each next filtering will be applied to the already filtered data (true), or to the initial data (false, default) |
smartFilter | (boolean) defines whether a filtering rule will be applied after adding and editing items of the collection |
For instance:
grid.data.filter(function (item) {
return item.a > 0 && item.b !== "Apple";
}, {
add: true,
smartFilter: true
});
grid.data.filter({
by: "a",
match: "Orange",
compare: function (value, match, item) {
if (item.a !== "Some") {
return val === "New";
}
return false;
}, {
add: true,
smartFilter: true
});
Back to top