开发者

How to capture jqGrid column changing events?

In our application we are using a jqGrid which supports hiding and reordering of columns. When the columns are hidden or reordered we want to store the new settings into our database. But to do this we somehow n开发者_如何学Pythoneed to capture the hiding or reordering event. Or possibly to capture when the colModel changes.

Is there any way to capture and handle these events?

Thanks.


You can use 'done' event of the columnChooser. 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 sortable option as

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

and not as sortable:true you will receive the notification about the new order of columns. See the source code of jqGrid for details. The array permutation with integers has the same meaning as in remapColumns functions (see my old answer for details).


You can capture column changes via the sortable parameter as mentinoed in Oleg's "update" above, or as discussed on jqGrid's message board.

However, please note that the array passed to your callback will be relative to the current column order. In other words, saving the array as is after moving multiple columns will not produce the desired results. See my answer on this other stackoverflow question.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜