group
Fired when the user is about to group the DataSource or modify the group descriptors state via the Grid group panel.
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.groups Array
The selected group descriptors.
e.preventDefault Function
If invoked prevents applying the group descriptors changes to the DataSource and to the group panel UI.
e.sender kendo.ui.Grid
The widget instance which fired the event.
Example - subscribe to the "group" 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" }
}
},
groupable: true,
group: function(e) {
if (e.groups.length) {
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(e.groups[0].field);
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(e.groups[0].dir);
}
}
});
</script>
Example - subscribe to the "group" 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" }
}
},
groupable: true
});
var grid = $("#grid").data("kendoGrid");
grid.bind("group", function(e) {
if (e.groups.length) {
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(e.groups[0].field);
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(e.groups[0].dir);
}
});
</script>