问题描述
我有一个启用了网格级别"sortable"选项的jqGrid.这使我可以左右拖动列以对其进行重新排序,这很棒.但是我想防止用户使用一个特定的列执行此操作,而使其他列不受影响.这可能吗?
I have a jqGrid with the grid-level 'sortable' option enabled. This lets me drag columns around to reorder them, which is great. But I want to prevent users from doing this with one specific column, leaving the others unaffected. Is this possible?
推荐答案
我发现您的问题非常有趣,因此我做了相应的演示,用于演示解决方案.在演示中,第一列日期"不可排序.
I find your question very interesting and so I made the corresponding demo which demonstrate the solution. On the demo is the first column "Date" unsortable.
我建议您阅读有关该主题的其他两个旧答案:此和.我的建议是基于相同的想法.
I recommend you to read two other old answers on the close subject: this and this. My suggesting are based on the same idea.
有内部jqGrid方法 sortableColumns 如果使用jqGrid的sortable: true
选项,将在内部使用. sortableColumns
方法使用jQuery Sortable实现,并将具有id="list"
的网格的items
选项初始化为值> th:not(:has(#jqgh_list_cb,#jqgh_list_rn,#jqgh_list_subgrid),: hidden)" .它使列"cb"
,"rn"
和"subgrid"
无法排序.如果使用jqGrid选项multiselect: true
,rownumbers: true
或subGrid: true
,则可以在网格中插入列.同样,您的列具有name: "invdate"
,则该列元素的对应ID为jqgh_list_invdate
.因此,可以使用以下选项sortable
There are internal jqGrid method sortableColumns which will be used internally if one uses sortable: true
option of jqGrid. The sortableColumns
method uses jQuery Sortable for the implementation and initializes items
options of the grid having id="list"
to the value ">th:not(:has(#jqgh_list_cb,#jqgh_list_rn,#jqgh_list_subgrid),:hidden)". It makes the columns "cb"
, "rn"
and "subgrid"
unsortable. The columns could be inserted in the grid if you use jqGrid options multiselect: true
, rownumbers: true
or subGrid: true
. In the same way is you have the column with name: "invdate"
then the corresponding id of the column element will be jqgh_list_invdate
. So one can use the option sortable
as the following
sortable: {
options: {
items: ">th:not(:has(#jqgh_list_cb,#jqgh_list_invdate,#jqgh_list_rn,#jqgh_list_subgrid),:hidden)"
}
}
使"invdate"
列不可排序.
这篇关于jqGrid-禁用特定列的重新排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!