开发者

How can I add multi-column sorting to jqgrid?

开发者 https://www.devze.com 2023-01-15 03:37 出处:网络
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 orde开发者_Go百科r is: column 2,

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 orde开发者_Go百科r 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

  • Export to PDF
  • Freeze columns
  • Sort by multiple columns
  • Group by multiple columns

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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消