1

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?

GregT
  • 1,300
  • 3
  • 16
  • 25
  • Oh, I think I found it here: http://stackoverflow.com/questions/2317199/jqgrid-with-column-reordering – GregT Sep 26 '12 at 19:30

1 Answers1

0

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.

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)"
    }
}

to make the "invdate" column unsortable.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798