How to capture jqGrid column change events?

In our application, we use jqGrid, which supports hiding and reordering columns. When the columns are hidden or reordered, we want to save the new settings in our database. But for this we need to somehow capture the concealment or reordering. Or perhaps to capture when changing colModel.

Is there a way to capture and handle these events?

Thanks.

+4
source share
2 answers

You can use the "done" columnChooser event . Here is an example:

var grid = $("list"); grid.navButtonAdd( '#pager', {caption:"", buttonicon:"ui-icon-calculator", title:"Column choose", onClickButton: function() { grid.jqGrid('columnChooser', { "done": function(perm) { if (perm) { this.jqGrid("remapColumns", perm, true); } // here you can do some additional actions } }); } }); 

UPDATED . If you define the sortable option as

 sortable: { update: function (permutation) { alert("sortable.update"); } } 

and not as sortable:true , you will be notified of a new column order. See jqGrid source code for more details. The permutation array with integers has the same meaning as in the remapColumns functions (see my old answer for details).

+4
source

You can record column changes using a sortable parameter, as described in Oleg’s “Update”, above, or, as discussed on the jqGrid message board .

However, note that the array passed to your callback will refer to the current column order. In other words, saving the array, as after moving several columns, will not produce the desired results. See my answer on this other stack question .

+1
source

Source: https://habr.com/ru/post/1334179/


All Articles