具有列重新排序的JQGrid [英] JQGrid with Column Reordering

查看:243
本文介绍了具有列重新排序的JQGrid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个jqgrid,可以在JQGrid中使用此选项对列进行重新排序

I have a jqgrid and I can reorder my columns with this option in my JQGrid

    jQuery("#list").jqGrid({
                sortable: true,
                ... 
});

此功能使我可以对所有列进行重新排序.但我希望某些列必须位于固定位置.有办法解决吗?

This functionality let me reorder ALL my columns. But I want that some columns must be on fixed places. Is there a way to solve this?

提前谢谢!

布鲁诺

推荐答案

永不言败. jqGrid使用jQueryUI的Sortable类执行列的拖放功能. http://jqueryui.com/demos/sortable/

Never say never. jqGrid uses jQueryUI's Sortable class to perform the column drag-n-drop function. http://jqueryui.com/demos/sortable/

要从可排序列的列表中删除一列,请在渲染网格(使用sortable:true)后运行以下两个命令.

To remove a column from the list of sortable columns, run these two commands after you've rendered your grid (with sortable: true).

// disable the sortable property on your target element 
// (which was applied when jqGrid rendered the grid)
$('tr.ui-jqgrid-labels').sortable({ cancel: 'th:#element_id'});
// update the list of sortable item's, and exclude your target element
$('tr.ui-jqgrid-labels').sortable({ items: "th:not(#element_id)" });

注意:如果您无法排序的列位于网格的左侧或右侧,则此方法最有效.否则,您仍然可以对它们周围的其他列进行重新排序.

Note: This works best if your unsortable columns are on the left or right edge of the grid. Otherwise, you will still be able to re-sort other columns around them.

:确保您了解两个可排序选项(网格级别和共同模型级别)之间的区别.在网格选项上,"sortable:true"表示可以通过拖放对列进行重新排序.在colmodel选项上,"sortable:true"表示您可以通过单击列标题来对行进行重新排序.在grid选项上将sortable设置为true不会降低到colmodel选项.但是,在colmodel上,sortable默认为true.

Also: Make sure you understand the difference between the two sortable options (grid level and colmodel level). On the grid options, "sortable: true" means the columns can be reorders by drag-and-drop. On the colmodel options, "sortable: true" means that you can reorder the rows by clicking on the column's header. Setting sortable to true on the grid options will not cascade down to the colmodel options. However, on the colmodel sortable is true by default.

这篇关于具有列重新排序的JQGrid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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