You can click the column header or call GridBase.orderBy method to sort by each column. In order to enable the user sort by clicking the column header, you should allow sorting in GridBase.operateOptions first. The sorting through calling the method has no relation to the property.
function (ev) {
grdMain.operateOptions().setSortingEnabled(ev.target.value);
}
Even if it is a sortable state in the grid level, you can also specify whether to enable the user sort by each column through DataColumn.sortable property. If click "Change Column Sortable" button below, it will alternately set whether to enable the sorting of the currently selected column.
function (ev) {
var column = grdMain.focusedIndex().column;
if (column instanceof DataLudi.DataColumn) {
column.setSortable(!column.sortable());
// If sortable is changed to false, the background color will be changed.
// Styles will be described in the examples below.
column.styles().setBackground(column.sortable() ? '#fff' : '#10000000');
}
}
The actual sorting runs based on Data Field which is connected to the column rather than the column unit. You can sort one or more fields at the same time, and field values being added will be sorted in a state of maintaining the order of the field values sorted first.
If specify sortStyle property as SortStyle.INCLUSIVE, you will be able to do multiple sorting. Please check it in Sort Style selection box above.
function (ev) {
grdMain.operateOptions().setSortStyle(ev.target.value);
}
SortStyle.REVERSE is the way to sort the field clicked later first.
If specify OperateOptions.keepFocusedRowWhenSort as true, the location of focused row will be kept after sorting.