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
andsortorder
parameters of jqGrid inside onSortCol event handler with respect of setGridParam. In case of two columns which having column indexes likefirstName
andlastName
for example the sorting by the first column only imply havingsortname
as 'firstName' andsortorder
as 'asc'. If you want to sort first by thefirstName
and bylastName
as the secont criteria you can setsortname
as 'firstName asc, lastName' andsortorder
as 'asc'. Your server program should of cause be able to interpret this, but if you just constructORDER BY
something likeORDER BY $sidx $sord
(see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:first_grid#php_and_mysql_example_file) it will work.A simple work around is to list all fields as a comma separated string ex.
On the server side just go ahead and parse the string and and craft your query.