Disable checkbox in "multiselect: true" mode for a specific row in jqgrid
I am displaying some data in jqgrid and I am using "multiselect: true" option. In a grid for a specific row, I want the checkbox not to appear, or if it does, it should be disabled. Can I do it? I am using jqgrid3.5.2.
Thanks in advance.
+2
Arka Chatterjee
source
to share
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
Madhu
source
to share
Just hide the "hideCol" label list column:
$("#mygridSelector").jqGrid({
//myGridOptions...
}).hideCol('cb');
+2
user288717
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
Najar
source
to share
Each checkbox has a unique identifier, which is a combination
"jqg _" + rowid - where rowid is the row id.
You can use the following code to make it invisible
$("#jqg_Q391")..css("visibility", "hidden");
0
Arka Chatterjee
source
to share