Using jqgrid with multiSelect=\"true\"
option. I am disabling rows and prevent its selection based on some flag status as mentioned below
Disable row(s) bas
I would suggest you to save the information whether all row are disabled or not inside of your custom option of jqGrid. The corresponding code could be like on the demo http://jsfiddle.net/OlegKi/aagxejj5/44/ which uses
rowattr: function (item, rd, rowid) {
var p = $(this).jqGrid("getGridParam");
if (rd.closed === "true" || rd.closed === true) {
return {"class": "ui-state-disabled ui-jqgrid-disablePointerEvents"};
} else {
p.isSomeEnabled = true;
}
},
beforeRequest: function () {
var p = $(this).jqGrid("getGridParam");
p.isSomeEnabled = false; // reset for the filling
},
loadComplete: function () {
var p = $(this).jqGrid("getGridParam"), $selAll = $("#cb_" + this.id);
if (p.isSomeEnabled) {
$selAll.removeClass("ui-state-disabled ui-jqgrid-disablePointerEvents");
$selAll.click(); // select all
// one need to trigger the click twice only because of bugs
// in case of usage old jQuery version
$selAll.click(); // select all
$selAll.prop("checked", true);
} else {
$selAll.addClass("ui-state-disabled ui-jqgrid-disablePointerEvents");
$selAll.prop("checked", false);
}
}
I placed one enabled on the second page, so one can switch the pages and see that the above code correctly work.
The checkbox in the header has the id which is combined from the "cb_" prefix and the grid id. So you can hide the element with
var myGrid = $("#list"); $("#cb_"+myGrid[0].id).hide();