sort

sort(fieldName, desc, unsort) – Perform sort operation over the datasource to which the grid is bound.

  • field name – the name of the field by which the datasouce will sort.
  • desc – bool value which indicates whether the sorting is descendant or ascendant.
  • unsort – bool value which indicates whether the sort expression will be cleared.
$("#grid").shieldGrid({
    dataSource: {
        data: [
            { ID: 1, name: "name1" },
            { ID: 2, name: "name2" }
        ]
    },
    sorting: true,
    columns: [
        { field: "ID" },
        { field: "name" }
    ]
});

var grid =$("#grid").swidget();
grid.sort("ID", false, false) // Result will be sorted data by ID ascending