Grid Sorting

The 'sortable' property enables or disables the data sorting.

To enable or disable the sorting of a Grid column, you can set its 'sortable' property to false.

When the sorting data type is Date, Number or Boolean, the 'type' property in the 'datafields' array should be set.

The 'sortcolumn' property specifies the default Grid sort column, i.e. when the grid is displayed, the data will be sorted. The 'sortdirection' property specifies the sort order of the sort column.

Sorting with the Grid API.

The 'sortby' function can be used to sort the Grid through the API. This function should be called when the grid data is fully loaded. The first parameter is the Column's DataField. The second parameter is the sort order - 'asc' or 'desc'.

To remove the sorting, call the "removesort" function.
When the data is sorted, the Grid raises the 'sort' event.

By default, when the sorting is enabled and the user clicks a column's header, the sort order is changed. The jqxGrid 'sorttogglestates' property can be used to modify this behavior. The possible values of this property are:

0 - disables toggling. The Grid is sortable only through the API.
1 - enables togging. Click on a column header toggles the sort direction. In this mode, there are 2 possible sort direction values - 'asc', and 'desc'.
2 - default toggle mode. Click on a column header toggles the sort direction. In this mode, there are 3 possible sort direction values - 'asc', 'desc' and null. When the sort direction is null, the sorting is cleared.

Custom Sorting

To override the default sorting logic, you need to set the 'sort' member of the Grid's source object to a custom sorting function. The Grid will pass two parameters to this function - the sort column's datafield and the sort direction.