I can add single column sorting to jqgrid, no problem. How can I add multi-column sorting to jqgrid?
That is, sort by column 1, then sort by column 2, the final sort order is: column 2, column 1
I can add single column sorting to jqgrid, no problem. How can I add multi-column sorting to jqgrid?
That is, sort by column 1, then sort by column 2, the final sort order is: column 2, column 1
Current version of jqGrid not support multi-column sorting.
On http://www.trirand.com/blog/ you can "Which feature do you like to see in jqGrid?" vote the answer
In general you can try to implement multi-sorting yourself by modifying sortname
and sortorder
parameters of jqGrid inside onSortCol event handler with respect of setGridParam. In case of two columns which having column indexes like firstName
and lastName
for example the sorting by the first column only imply having sortname
as 'firstName' and sortorder
as 'asc'. If you want to sort first by the firstName
and by lastName
as the secont criteria you can set sortname
as 'firstName asc, lastName' and sortorder
as 'asc'. Your server program should of cause be able to interpret this, but if you just construct ORDER BY
something like ORDER BY $sidx $sord
(see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:first_grid#php_and_mysql_example_file) it will work.