filter

filters data items in a component

void filter(function|object rule,object config);

Parameters

rulefunction|objectthe filtering criteria
configobjectoptional, defines the parameters of filtering

Example

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
});

Related samples

Details

Calling the filter() method without parameters reverts the component to the initial state:

grid.data.filter();


The rule parameter:

  • if set as a function, the filtering will be applied by the rule specified in the function:
grid.data.filter(function (item) {
    return item.a > 0 && item.b !== "Apple";
});
  • if set as an object, the parameter has the following attributes:

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:

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