如何将多列排序添加到jqgrid? [英] How can I add multi-column sorting to jqgrid?

查看:220
本文介绍了如何将多列排序添加到jqgrid?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以将单列排序添加到jqgrid,没问题.如何向jqgrid添加多列排序?

I can add single column sorting to jqgrid, no problem. How can I add multi-column sorting to jqgrid?

也就是说,按第1列排序,然后按第2列排序,最终的排序顺序是:第2列,第1列

That is, sort by column 1, then sort by column 2, the final sort order is: column 2, column 1

推荐答案

jqGrid的当前版本不支持多列排序.

Current version of jqGrid not support multi-column sorting.

http://www.trirand.com/blog/上,您可以执行某项功能您想在jqGrid中看到吗?"投票答案

On http://www.trirand.com/blog/ you can "Which feature do you like to see in jqGrid?" vote the answer

  • 导出为PDF
  • 冻结列
  • 按多列排序
  • 按多列分组
  • Export to PDF
  • Freeze columns
  • Sort by multiple columns
  • Group by multiple columns

通常,您可以尝试通过修改 onSortCol 事件处理程序="noreferrer"> setGridParam .例如,在两列的列索引如firstNamelastName的情况下,第一列的排序仅意味着将sortname作为'firstName'并将sortorder作为'asc'.如果要首先按firstNamelastName进行排序,则可以将sortname设置为"firstname asc,lastName",将sortorder设置为"asc".您的服务器程序应该可以解释这一点,但是如果您仅构造ORDER BY之类的内容,例如ORDER BY $sidx $sord(请参阅

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.

这篇关于如何将多列排序添加到jqgrid?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆