在网格加载时禁用单元格(dhtmlx)

时间:2014-03-05 15:40:01

标签: javascript dhtmlx

我在Ruby on Rails项目中使用DHTMLX Grid。

我有几个“验证”,如果在一些单元格上选择了某个值,则启用/禁用单元格(请参阅我对此问题的第一个问题 - > Change cell value if checkbox selected - dhtmlxGrid in RoR

这样可以正常工作,但我想在第一次加载网格时运行这些验证,这可能吗?

我有这样的事情:

grid.attachEvent("onEditCell", function(stage,rId,cInd,nValue,oValue){
        if (stage == 2 && cInd == 6)
           {
              // If Resultado = Negativo
              if (nValue == 1){
                 grid.cells(rId,7).setDisabled(true);
                 grid.cells(rId,8).setDisabled(true);
                 grid.cells(rId,9).setDisabled(false);
                 return true;
              }
                            else {
              grid.cells(rId,9).setDisabled(false);
              return true;
              }
           }

但是我想在网格加载上运行这些相同的验证。我怎么能这样做?

1 个答案:

答案 0 :(得分:3)

请尝试使用以下代码:

grid.load(url,function(){  //loading data to the grid
        grid.forEachRow(function(id){  //iterating through the rows
            var val=grid.cells(id,6).getValue();  // getting the value of the cell
            if(val==1){  // your custom validation logic
                grid.cells(id,7).setDisabled(true);
                grid.cells(id,8).setDisabled(true);                
            }
            grid.cells(id,9).setDisabled(false); 
        });
    });
相关问题