jQuery Grid Sorting

The Grid component supports sorting out of the box. The default sorting is enabled by setting the sorting property to true.
This is demonstrated in the following code snippet:

 $("#grid3").shieldGrid({
     dataSource: {
         data: [
            { ID: 1, name: "name1" },
            { ID: 2, name: "name2" }
        ]
     },
     sorting: true
});

Sorting programatically
One can also sort the ShieldUI grid component programatically, without relying on the standard user header click to initiate the sort.
This can be done programatically, for example by clickin on a button outside the grid and calling the sort function. This is demonstrated in the code snippet below:



 
        function sortDesc() {
            $("#grid1").swidget().sort("UnitPrice", true, false);
        }

As can be seen from the code, the approach requires:
1.Finding the grid container by id.
2.Calling the sort method, by passing it the column/field name as a first agrument.