开发者

event on selecting columns in jqGrid

开发者 https://www.devze.com 2022-12-08 22:27 出处:网络
Is there an event in jqGrid when a user uses the column dialog to add or remove columns. If not, is there another way to track column change. I need this to persist selected 开发者_StackOverflowcolumn

Is there an event in jqGrid when a user uses the column dialog to add or remove columns. If not, is there another way to track column change. I need this to persist selected 开发者_StackOverflowcolumns when I show the grid on different pages.


Welllll.... You're showing the dialog yourself, right? So you're already in your own code?

I'm guessing that what you really mean is "when the user clicks 'Submit'?" If so, look at afterSubmitForm.


I think he means the column changing dialog from the jqGrid 3.6 demo.

Presently there is not an event for this, but there may still be a way. Grid method columnChooser accepts the following option in the jqGrid source:

"done" : function(perm) { if (perm) self.jqGrid("remapColumns", perm, true) },

Try providing your own version of the function (see the demo page for where to call this):

jQuery("#colch").jqGrid('columnChooser', {
   "done" : function(perm) { 
       if (perm) {
          jQuery("#colch").jqGrid("remapColumns", perm, true) 

          ( ... your code here ... )
       }
   }
});

Assuming this works, you could use the following code to figure out which columns are hidden:

var colModel = $("#mygrid").getGridParam("colModel");
for (var i = 0; i < colModel.length; i++){
    if (colModel[i].hidden) { 

        ... store away colModel.name somewhere ... 

    }
}
0

精彩评论

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