Search code examples
jqueryjqgrid

jqGrid - saving the colmodel to local cache


I have used setColumns function to show/hide columns dynamically on client-side.

Now I want to save the selected columns to local cache. how to do that.

the following is the code I have used

$("#spsGrid").navButtonAdd('#prPager', {
  caption: "Show/Hide Columns",
  title: "Click here to select Columns to view",
  onClickButton: function() {
    var params = {width:500,modal:true,drag:true};
    jQuery("#list").setColumns(params);
  },
  position: "last"
});

Now, whenever the user selects few columns and clicks ok button inside the dialog box, I have to extract the selected columns and save it as user preferences. So, How can we attach an event to OK button inside this Show/Hide columns dialog box?


Solution

  • As SetColoumns plugin is not supported directly by JQGrid, I have used ColumnChooser option. It solved my problem.

    Refer this link Is there a full working example for a jqGrid ColumnChooser?