When I add multiselect: true
to my jqgrid, I see that jqgrid adds a checkbox for each row. Each checkbox that is displayed is unchecked. Is there a way I can preset these checkboxes based on data I'm using to populate my grid? For example, if my grid has a column called selected, and a row I'm displaying has a selected value of 1, I'd like to display the checkbox for that row as being checked. When a row's selected field is 0, I'd like to keep the checkbox as unchecked. Is this possible?

- 1,045
- 1
- 24
- 45
3 Answers
The answer on your question depends on the fork of jqGrid, which you use. I develop free jqGrid fork and implemented multiPageSelection: true
option. One need just fill selarrrow
array (which you can do, for example, inside of beforeProcessing
based on the data returned from the server). Look at the demo created for the answer. It shows that the selarrrow
array contains the ids more as on the current page. On paging or during initial filling free jqGrid set the state of chechboxes based on the selarrrow
array. In the way it works effective like custom formatters, rowattr
or cellattr
.
If you can't upgrade to free jqGrid then you can call setSelection
inside of loadComplete
(see the old answer). It will work slower as in case of usage multiPageSelection: true
, but it will work.
In loadComplete
, have something like this
var i;
var rowids = $('#myTable').jqGrid('getDataIDs');
for (i = 0;i < count = rowids.length;i+=1) {
// condition to mark it check
$('#myTable').jqGrid('setSelection', rowids[i], false);
}
Cheers!

- 198
- 1
- 12
You will need to loop through the data and apply the check.

- 354
- 2
- 15
-
I'm curious on how I would do that, given that the "cb" column that jqgrid adds on the fly is not part of the column model I'm defining. – Michael Sobczak Sep 26 '16 at 19:04
-
Yes you will need to do this after the column are generated. based in index id which is generated for all the checkbox – Yogesh Sep 26 '16 at 19:08
-
How do I know when the columns are generated? – Michael Sobczak Sep 26 '16 at 19:16
-
Once the page is redered. Or better write a custom function using formatter options to apply the change. – Yogesh Sep 26 '16 at 19:40