Edit this page

filter

Gets or sets the filter configuration.

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();
console.log(view.length);
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();
console.log(filter.logic);  // displays "and"
console.log(filter.filters[0]); //displays '{field: "name", operator: "startswith", value: "Jane"}'
</script>
Is this article helpful? Yes / No
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article

close
Dummy