2014-03-05 78 views
1

我在Ruby on Rails项目上使用DHTMLX网格。禁用网格加载单元格(dhtmlx)

我有几个“验证”如果少数细胞选择一些值启用/禁用细胞(见对这个问题我的第一个问题 - >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; 
       } 
      } 

但我想运行对电网负荷这些相同的验证。我怎样才能做到这一点?

回答

2

请尝试使用下面的代码:

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

它的工作原理,谢谢!我错过了forEachRow :)再次感谢您的帮助 – lbramos