Cant break through a treegrid iteration loop--need help urg



Hi i am using the typical treegrid iteration

using the following method of iteration

mygrid._h2.forEachChild(0,function(row){
     var id=row.id;
/// if(id is unique - break out of the loop)

}

I am currently iterating through 1000 rows, if a condition is satisfied, i need to abruptly terminate out of the iteration
using break keyword does not terminate the loop- throws a javascript error saying that break method only works within a loop
tried returning false through the callback function, that doesnt work either
any other method abruptly break out of the iteration??

There is no way to break iteration in case of forEachChild
The operation cost of iterator is pretty small, and must not cause slowness. You can try to use the global flag to prevent unnecessary operations

var find = false;
grid._h2.forEachChild(function(id){
if (find) return; // block unnecessary execution
if (some_condition ) find = id;
});