sort

Fired when the user is about to modify the current state of sort descriptors of DataSource via the sort 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.sort Object

The selected sort descriptors.

e.preventDefault Function

If invoked prevents applying the changes to the DataSource.

e.sender kendo.ui.Grid

The widget instance which fired the event.

Example - subscribe to the "sort" 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" }
      }
    },
    sortable: true,
    sort: function(e) {
/* The result can be observed in the DevTools(F12) console of the browser. */
      console.log(e.sort.field);
/* The result can be observed in the DevTools(F12) console of the browser. */
      console.log(e.sort.dir);
    }
  });
</script>

Example - subscribe to the "sort" 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" }
      }
    },
    sortable: true
  });
  var grid = $("#grid").data("kendoGrid");
  grid.bind("sort", function(e) {
/* The result can be observed in the DevTools(F12) console of the browser. */
    console.log(e.sort.field);
/* The result can be observed in the DevTools(F12) console of the browser. */
    console.log(e.sort.dir);
  });
</script>
In this article