带列重新排序的JQGrid
我有一个jqgrid,我可以在我的JQGrid中使用此选项重新排序我的列
jQuery("#list").jqGrid({ sortable: true, ... });
这个function让我重新排序我的所有列。 但是我想要一些列必须在固定的地方。 有办法解决这个问题吗?
提前致谢!
布鲁诺
永远不要把话说绝了。 jqGrid使用jQueryUI的Sortable类来执行列拖放function。 http://jqueryui.com/demos/sortable/
要从可排序列列表中删除列,请在渲染网格后运行这两个命令(使用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)" });
注意:如果您的不可移动列位于网格的左边缘或右边缘,则此方法效果最佳。 否则,您仍然可以重新排序它们周围的其他列。
另外:确保您了解两个可排序选项(网格级别和colmodel级别)之间的差异。 在网格选项中,“sortable:true”表示可以通过拖放重新排序列。 在colmodel选项中,“sortable:true”表示您可以通过单击列的标题对行重新排序。 在网格选项上将sortable设置为true将不会级联到colmodel选项。 但是,在colmodel上,sortable默认为true。
现在在2013年,您可以定义“sortable”的“exclude”参数,如下所示:
sortable: { exclude: '#'+ grid[0].id +'_actions_buttons' },
您可以为colModel
每个列设置sortable
colModel: [{ name: 'name', index: 'name', sortable: true },...
查看文档非常有用。
这在jqgrid中是不可能的。 我也搜索了很长时间。 我尝试的一切都失败了。