1

I'm using DHTMLX Grid on a Ruby on Rails project.

I have several "validations" that enable/disable cells if some value is selected on a few cells (see my first question on this problem -> Change cell value if checkbox selected - dhtmlxGrid in RoR)

This works fine but I want to run these validations also when the grid loads for the first time, is this possible?

I have something like this:

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;
              }
           }

But I want to run these same validations on grid loading. How can I do this?

Community
  • 1
  • 1
lbramos
  • 327
  • 1
  • 6
  • 19

1 Answers1

3

Please, try to use the following code:

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); 
        });
    });
Paul
  • 1,656
  • 11
  • 16