I would suggest you to disable some checkboxed from the be selectable with respect of "disabled" attribute. To make full implementation you will need
- set "disabled" inside of
loadComplete
event handle
- additionally prevent selection of disabled rows inside
beforeSelectRow
event handle
- to have support of "select all" checkbox in the header of the multiselect column implement
onSelectAll
event handle which fix selection of disabled rows.
The corresponding demo can you see here. The most important part of the code is here:
var grid = $("#list10"), i;
grid.jqGrid({
//...
loadComplete: function() {
// we make all even rows "protected", so that will be not selectable
var cbs = $("tr.jqgrow > td > input.cbox:even", grid[0]);
cbs.attr("disabled", "disabled");
},
beforeSelectRow: function(rowid, e) {
var cbsdis = $("tr#"+rowid+".jqgrow > td > input.cbox:disabled", grid[0]);
if (cbsdis.length === 0) {
return true; // allow select the row
} else {
return false; // not allow select the row
}
},
onSelectAll: function(aRowids,status) {
if (status) {
// uncheck "protected" rows
var cbs = $("tr.jqgrow > td > input.cbox:disabled", grid[0]);
cbs.removeAttr("checked");
//modify the selarrrow parameter
grid[0].p.selarrrow = grid.find("tr.jqgrow:has(td > input.cbox:checked)")
.map(function() { return this.id; }) // convert to set of ids
.get(); // convert to instance of Array
}
}
);
UPDATED: Free jqGrid supports hasMultiselectCheckBox
callback, which can be used to create multiselect checkboxes not for all rows of jqGrid. One can use rowattr
to disable some rows additionally. As the result one will get the described above functionality in more simple way. It's recommended to use multiPageSelection: true
option additionally for free jqGrid with local data (datatype: "local"
or loadonce: true
). The option multiPageSelection: true
will hold the array selarrrow
on paging. It allows "pre-select" some rows by filling the corresponding ids inselarrrow
. See UPDATED part of the answer and the answer with the demo for additional information.