Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting filters used in KendoUI Grid

In KendoUI, I have a grid with filters on. I am more interested in knowing all the filters used by user for saving purpose so that next time user comes in, they can be auto-fill. How do I get all the filters used?

like image 415
bobsov534 Avatar asked Oct 18 '13 15:10

bobsov534


People also ask

How do I filter a Kendo UI Grid?

By default, the filtering functionality of the Kendo UI Grid is disabled. To control filtering in the Grid, use the filterable property. Only columns that are bound to a field can be filterable. To enable filtering on a column bound to an object, bind the column to a field of that object.

How do I set the default filter in kendo grid?

Solution. On the dataBound event of the grid, find the filter dropdown and select() the desired default filter option. On the filter event of the Grid, if the filter is cleared, select the desired default filter option.

How do I search in kendo grid?

To add a search box into a kendo grid we need to add Toolbar and search properties while initializing the kendo grid. Fields is an array of each field defined for the kendo grid. From the above snippet, the search will be applied for the name and age field of the grid.


1 Answers

Not sure how your code looks but you should be able to get the Grid's datasource object and call the method filter() to get the currently applied datasource filters. Take a look at the example below taken from here:

<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>
like image 150
ramsey_tm Avatar answered Dec 05 '22 04:12

ramsey_tm