2010-05-27 46 views

回答

5

我居然找到了一個方法:

grid.jqGrid('setGridParam',{ 
       afterInsertRow: function(rowid, aData, rowelem) { 

        var rowData = grid.getRowData(rowid); 
        if(**Condition**){ 
         $('tr#'+rowid, grid) 
         .children("td.sgcollapsed") 
         .html("") 
         .removeClass('ui-sgcollapsed sgcollapsed'); 
        } 
       } 
      }); 

有一點問題的。代碼@Frank刪除了圖標,但'click'事件仍然被觸發。嘗試解除「點擊」事件似乎不起作用,可能是因爲它稍後會附加(可能在gridComplete)。無論如何,我認爲單擊事件是使用「ui-sgcollapsed sgcollapsed」類之一附加的,所以如果將它們刪除,則不會附加該事件。

希望它有幫助。

0

不幸的是,這裏沒有jqGrid API。您將不得不等待,直到網格創建完成,然後可能從loadComplete事件中,您需要手動循環遍歷所有行並禁用選定的行。

如果您檢查組成網格的DOM元素,則可以找出一種方法來爲選定行移除/禁用擴展器。也許通過使用jQuery.remove

2

一下添加到gridConfig

afterInsertRow: function(rowid, aData, rowelem) { 
    // Remove the subgrid plus button except for rows that have exceptions 
    if (CONDITION) { 
     $('#' + rowid).children("td.sgcollapsed").unbind().html(""); 
    } 
}, 
+0

作爲Madalin提到,這僅刪除圖標。用戶仍然可以點擊進入,這意味着功能仍然存在。 – Joseph 2014-05-29 14:10:11

0

如果你正試圖禁用或隱藏子網格展開和摺疊按鈕,然後在loadcomplete使用,

jQuery("#GridTeableID").jqGrid('hideCol', "subgrid");