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?
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.
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.
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.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With