filter

Gets or sets the filter configuration.

A list of the supported operators you can find in this filter operator configuration article.

Parameters

value Object (optional)

The filter configuration. Accepts the same values as the filter option (check there for more examples).

Returns

Object—The current filter configuration. Returns null if no filter criteria are currently applied. Returns undefined if the DataSource instance has not performed filtering so far.

Example - set the data source filter

<script>
var dataSource = new kendo.data.DataSource({
  data: [
    { name: "Jane Doe" },
    { name: "John Doe" }
  ]
});
dataSource.filter( { field: "name", operator: "startswith", value: "Jane" });
var view = dataSource.view();
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(view.length);
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(view[0].name); // displays "Jane Doe"
</script>

Example - get the data source filter

<script>
var dataSource = new kendo.data.DataSource({
  data: [
    { name: "Jane Doe" },
    { name: "John Doe" }
  ],
  filter: { field: "name", operator: "startswith", value: "Jane" }
});
var filter = dataSource.filter();
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(filter.logic);  // displays "and"
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(filter.filters[0]); //displays '{field: "name", operator: "startswith", value: "Jane"}'
</script>
In this article