You can include on your html page an additional element like checkbox or a select with options which allows the user to choose the sort order. To read information about users selection you can use
var addSortInfo = jQuery("#orderByCost").is(':checked');
or
var addSortInfo = jQuery("#selectList option:selected").val();
Then you can use postData option of jqGrid to send additional data with all requests to the server. The value of the postData
parameter can be an object like {mySortInfo: addSortInfo}
where "mySortInfo" is the name of additional parameter which you will see on the server side together with sidx
, page
and other standard parameters of every requests. In case of HTTP GET requests the data from postData
will be appended to the server url and in case of HTTP POST the data will be added to the request body.
You can also use functions inside of postData
. The advantages of this approach you can read in http://stackoverflow.com/questions/2928371/how-to-filter-the-jqgrid-data-not-using-the-built-in-search-filter-box/2928819#2928819 for more information.