In this chapter you'll find out how to implement iterators for dhtmlxGrid.
The stated below technique isn't used in the smart rendering mode.
for (var i=0; i<mygrid.getRowsNum(); i++){
mygrid.cellByIndex(i,0).setValue(i); // i - the index of a row in the grid
};
The method forEachRow iterates over all rows in the grid.
mygrid.forEachRow(function(id) {
mygrid.cellById(row_id,0).setValue(id); //id - the row id
});
Related sample: Multiline cells
When you apply grouping to the grid, you can use the forEachRowInGroup method to provide iteration over rows of a specific group.
mygrid.forEachRowInGroup(name,function(id){
mygrid.cellById(row_id,col_ind).setValue(id); //id - the row id
});
where name is the key value of the group.
The stated below technique isn't used in the smart rendering mode.
for (var i=0; i<mygrid.getColumnCount(); i++){
alert(mygrid.cellById(row_id,col_ind).getValue()); //i-index of a column (zero-based numbering)
}
The method forEachCell iterates over all cells of the specified row.
mygrid.forEachCell(row_id,function(cellObj,col_index){
cellObj.setValue(col_index)
);