在Dojo dgrid中禁用行

时间:2013-10-03 11:55:50

标签: dojo dgrid

我想基于其中一个单元格值禁用dojo dgrid中的某些行。我使用了Dgrid的选择器和选择mixin。

我在特定单元格上使用renderCell函数并且能够获取单元格值。如果单元格值是“somedata”,那么我想禁用行即复选框选择器。请告诉我如何实现这一点?

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

2 个答案:

答案 0 :(得分:2)

selector's documentation所示,您可以通过在选择器列的列定义中提供disabled函数来控制禁用特定行的复选框。该函数接收该行的完整项目,因此您可以根据所需项目中的任何数据建立条件。

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

答案 1 :(得分:0)

您还可以覆盖网格中的allowSelect()方法:

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

此方法由其他方法调用,以确定行是否可选。