2013-10-03 32 views
1

我想根據其中一個單元格值禁用dojo dgrid中的某些行。我已經使用了Dgrid的選擇器和選擇混合。禁用Dojo中的一行dgrid

我在特定的單元格上使用了renderCell函數,並且能夠獲取單元格值。如果單元格值爲「somedata」,那麼我想禁用該行,即複選框選擇器。請告訴我如何實現此目的?

 renderCell : function(object, value, node, options) { 
    if(value == "somedata") { 
      //want to disable that row in the grid 
     } 
+0

你能提供更多關於你想要「禁用」該行的細節嗎? – BuffaloBuffalo

+0

我想禁用該行的複選框。所以該行不能被檢查。我已經使用Dgrid的選擇器和選擇混合在grid.selectorType是「複選框」 – SSayee

回答

2

selector's documentation看到的,則可以通過在用於選擇列的列定義提供disabled功能控制複選框的特定行的禁用。該函數接收該行的完整項目,因此您可以根據需要的項目中的任何數據來確定條件。

selector({ 
    // other properties e.g. field/label here... 
    disabled: function (item) { 
     return item.someField === "someData"; 
    } 
}) 
+0

謝謝,它的工作。 – SSayee

0

您還可以覆蓋在網格中的allowSelect()方法:

allowSelect:function (row) { 
    return true/false; // something based on the row you are passing     
} 

,此方法被通過其他方法調用,以確定行是否可選擇。