Disable checkbox in "multiselect: true" mode for a specific row in jqgrid
4 answers
Try the following:
loadComplete: function() {
var ids =jQuery("#TableId").jqGrid('getDataIDs');
for(var i=0;i < ids.length;i++){
var rowId = ids[i];
var Status = jQuery("#TableId").jqGrid('getCell',ids[i],'Status');
if(condition matches){
jQuery("#jqg_TableId_"+rowId).attr("disabled", true);
}
}
}
To avoid row selection when clicking anywhere in a disabled row:
beforeSelectRow: function(rowid, e) {
if( $("#jqg_TableId_"+rowid).attr("disabled") ){
return false;
}
return true;
}
+7
source to share
this code works fine in my application, please try it yourself.
below code is very simple and straightforward
gridComplete: function() //when first time load data
{
if(consignNo != "") //this is my condition when my check box is disable when load data
{
$("#jqg_batchList_" + ids[i]).attr("disabled", true);
}
},
beforeSelectRow: function(rowid, e) //this function is used when you select rows
{
//means when your check box is disabled,you can't check your check box
if( $("#jqg_batchList_"+rowid).attr("disabled") )
{
return false;
}
return true;
},
onSelectAll: function(aRowids,status) // this function is used when you select all check box
{
if (status)
{
for(var i=0;i<aRowids.length;i++)
{
if( $("#jqg_batchList_"+aRowids[i]).attr("disabled"))
{
$("#jqg_batchList_" + aRowids[i]).removeAttr("checked");
}
}
}
},
//added by Najarhasan hasnutech@gmail.com just copy code and put your jqgrid code
+1
source to share