Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Manoj Kumar on Mar 06, 2009 04:17
open dhtmlx forum
How can I break the loop of this._grid.forEachRow(function(id){}); and return false;

I am using following code for cell data validation. But 'return false' is not breaking the loop.

this._grid.forEachRow(function(id){
var notional = this.cells(id,2).getValue();
if(!prototype._validateDecimal(notional,5))
{
alert (“Error!”);
this.selectCell(this.getRowIndex(id),2);
this.editCell();
return false;
}
});
Answer posted by Support on Mar 06, 2009 05:54
Actually you can't. The only solution - use custom looping code instead of built in one 

var max = mygrid.getRowsNum();
for (var i=0; i<max; i++){
   var notional = this.cells2(i,2).getValue(); 
   if(!prototype._validateDecimal(notional,5)) 
   { 
      alert (“Error!”); 
      this.selectCell(i,2); 
      this.editCell(); 
      return false; 
   } 
}


});