filter
Fired when the user is about to filter the DataSource via the filter UI.
The event handler function context (available via the this
keyword) will be set to the widget instance.
Introduced in the Kendo UI 2016 R3 (2016.3.914) release.
Event Data
e.filter Object
The selected filter descriptor. If null
the filter has been cleared for example by click on the clear
button.
e.field String
The field for which the filter is constructed.
e.preventDefault Function
If invoked prevents adding the filter descriptor to the DataSource.
e.sender kendo.ui.Grid
The widget instance which fired the event.
Example - subscribe to the "filter" event during initialization
<div id="grid"></div>
<script>
$("#grid").kendoGrid({
columns: [
{ field: "name" },
{ field: "age" }
],
dataSource: {
data: [
{ id: 1, name: "Jane Doe", age: 30 },
{ id: 2, name: "John Doe", age: 33 }
],
schema: {
model: { id: "id" }
}
},
filterable: true,
filter: function(e) {
if (e.filter == null) {
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log("filter has been cleared");
} else {
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(e.filter.logic);
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(e.filter.filters[0].field);
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(e.filter.filters[0].operator);
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(e.filter.filters[0].value);
}
}
});
</script>
Example - subscribe to the "filter" event after initialization
<div id="grid"></div>
<script>
$("#grid").kendoGrid({
columns: [
{ field: "name" },
{ field: "age" }
],
dataSource: {
data: [
{ id: 1, name: "Jane Doe", age: 30 },
{ id: 2, name: "John Doe", age: 33 }
],
schema: {
model: { id: "id" }
}
},
filterable: true
});
var grid = $("#grid").data("kendoGrid");
grid.bind("filter", function(e) {
if (e.filter == null) {
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log("filter has been cleared");
} else {
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(e.filter.logic);
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(e.filter.filters[0].field);
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(e.filter.filters[0].operator);
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(e.filter.filters[0].value);
}
});
</script>