3

I am showing some data in jqgrid and I am using the option “multiselect:true”.In the grid, for a specific row, I want the checkbox not to be show or if it is shown then it should be disabled.Can I do this??I am using jqgrid3.5.2.

Thanks in advance.

Arka Chatterjee
  • 327
  • 2
  • 4
  • 9

4 Answers4

7

Try this:

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 on click anywhere on disabled row:

beforeSelectRow: function(rowid, e) {
    if( $("#jqg_TableId_"+rowid).attr("disabled") ){
        return false;
    }
    return true; 
}
Garrett Hyde
  • 5,409
  • 8
  • 49
  • 55
Madhu
  • 81
  • 1
  • 2
  • When I tried doing this in 2020, I ran into a problem that when select all is clicked the disabled radio button also got selected. The answer @ https://stackoverflow.com/a/33629176 has better solution and solved that issue as well. – Ramesh Sep 10 '20 at 15:44
2

Simply hide the combo box column with the "hideCol" method :

$("#mygridSelector").jqGrid({
    //myGridOptions...    
}).hideCol('cb');
1

this code is working fine in my application please try your self..

below code is very simple and well understandable

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
Najar
  • 11
  • 1
0

Every checkbox has uniquie id which is combination of

“jqg_”+rowid – where the rowid is the id of the row.

You can use the following code to make it invisible

$("#jqg_Q391")..css("visibility", "hidden");
Harry
  • 87,580
  • 25
  • 202
  • 214
Arka Chatterjee
  • 327
  • 2
  • 4
  • 9