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
A simple work around is to list all fields as a comma separated string ex.
sortname: 'customer_id, store_id, start_date'
On the server side just go ahead and parse the string and and craft your query.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With