Maintain checkboxes across pages

Mar 30, 2012 at 10:28 PM

I need to introduce a checkbox column, let the user select multiple rows across pages and then if the user wants to change the selection then reload the grid with the previously selected values as already checked.

 

So here are the questions that I have:

1. Does jqGrid maintain checkbox selection across pages? If not then what is the best solution, if yes then what the configuration option?

2. Is there a way to refresh the grid by an external button click? same behaviour that is seen by click refresh \ reload button in the Navigator bar.

3. What's the best way to select the checkboxes for the previously selected rows?

Coordinator
Apr 1, 2012 at 9:09 AM

So I'm assuming that you are using MultiSelect option for adding the columns. In that case I would answear this:

  1. There is no built-in mechanism in jqGrid to keep the selection across the pages.
    You need to store the selected rows ids by yourself. You can get them by using $('#grid').jqGrid('getGridParam', 'selarrrow') method (it returns an array).
  2. You just need to call $('#grid').trigger('reloadGrid', [{page:1}]) method. In case you need to clear search options, please take a look here: http://stackoverflow.com/questions/3865584/jqgrid-how-to-reset-search-options
  3. You need to call $('#grid').jqGrid('setSelection', id, false) for every id returned by getGridParam. This is best done in gridComplete event (GridComplete).
Apr 3, 2012 at 9:56 PM

Thanks a lot TPeczek, for your reply.

I'm not sure if I'm going to use this solution. I changed my approach a bit.



BTW, Awesome tool . :)