Skip to main content

filter()

filters controls by some criteria

filter(rule?: IFilterMode | IFilterCallback, config?: IFilterConfig): void;

Parameters:

  • rule: function | object - the filtering criteria
  • config: object - optional, defines the parameters of filtering

Example

treeGrid.data.filter({    by: "name",    match: "Angola"});

Related sample: TreeGrid. Basic Filter

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

tree.data.filter();    // show all

The rule parameter:

  • if set as a function, the filtering will be applied by the rule specified in the function:
tree.data.filter(function (item) {    return item.value.toLowerCase().indexOf("a") !== -1;});
  • if set as an object, the parameter has the following attributes:
by(string) mandatory, the id of a column
match(string) mandatory, a pattern to match
compare(function) optional, a function for extended filtering that takes three parameters:
  • value - the value to compare (e.g. a column in a row for Grid)
  • match - a pattern to match
  • item - a data item the values of which should be compared (e.g. a row)
treeGrid.data.filter({    by: "name",    match: "Angola"});

The config parameter may contain the following properties:

type(string) optional, defines the area the filtering will be applied: "all", "level", "leafs"
level(number) optional, the level the filtering will be applied to
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