I have kendo-grid in my application.And its have filterable "true".When we apply the filtering then grid items are filtered and grid size also re-sized. when we clear the text in filter column then automatically grid display the items which is displayed in the page-load with out pressing clear button.is it possible? My grid code is
var grid = $("#grid").kendoGrid({
dataSource: {
type : "odata",
transport : {
read: "http://demos.kendoui.com/service/Northwind.svc/Orders"
},
schema : {
model: {
fields: {
OrderID : { type: "number" },
Freight : { type: "number" },
ShipName : { type: "string" },
OrderDate: { type: "date" },
ShipCity : { type: "string" }
}
}
},
pageSize : 10
},
filterable: true,
sortable : true,
pageable : true,
columns : [
{
field : "OrderID",
filterable: false
},
"Freight",
{
field : "OrderDate",
title : "Order Date",
width : 100,
format: "{0:MM/dd/yyyy}"
},
{
field: "ShipName",
title: "Ship Name",
width: 200
},
{
field: "ShipCity",
title: "Ship City"
}
]
}).data("kendoGrid");
if you call
there is a possibility, that you erase whole dataSource filter, not only fields which are in grid. I mean dataSource can be prefiltered for some reason.
I developed method, which remove only filter of grid.
And here is second method. It is separated because it can be call recursively:
Method can be called like this:
Recursion is there because dataSource filter can look like:
and method is recursively called on all nested 'filters' arrays. Filter above is like:
The method is not perfect and a few tested. I hope this helps someone.
You need to use the filter method of the grid's data source: