2009-08-31 44 views
2

我在jqgrid中顯示了一些數據,並且使用了選項「multiselect:true」。在網格中,對於特定的行,我希望複選框不顯示或如果顯示,那麼它應該被禁用。我可以做到這一點??我使用jqgrid3.5.2。禁用jqgrid中特定行的「multiselect:true」模式複選框

在此先感謝。

+0

一個更完整的解決方案,請訪問:HTTP:// stackoverflow.com/a/5260847/16911 – AaronSieb 2015-01-12 17:25:05

回答

0

每個複選框有各式獨特的ID這是

組合「jqg _」 + ROWID - 其中ROWID是該行的ID。

您可以使用下面的代碼,使其隱形

$("#jqg_Q391")..css("visibility", "hidden"); 
2

簡單地用 「hideCol」 方法隱藏組合框柱:

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

試試這個:

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); 
     } 
    } 
} 

爲了避免在禁用行上的任何位置點擊行選擇:

beforeSelectRow: function(rowid, e) { 
    if($("#jqg_TableId_"+rowid).attr("disabled")){ 
     return false; 
    } 
    return true; 
} 
1

此代碼工作正常在我的應用程序,請嘗試你的自我..

下面的代碼很簡單,很好理解

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 [email protected] just copy code and put your jqgrid code