gpt4 book ai didi

jquery - 具有列重新排序功能的 JQGrid

转载 作者:行者123 更新时间:2023-12-01 00:47:06 25 4
gpt4 key购买 nike

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

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

此功能让我可以对所有列重新排序。但我希望某些列必须位于固定位置。有办法解决这个问题吗?

提前致谢!

布鲁诺

最佳答案

永远不要说永远。 jqGrid使用jQueryUI的Sortable类来执行列拖放功能。 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 上,默认情况下可排序为 true。

关于jquery - 具有列重新排序功能的 JQGrid,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2317199/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com