The base element of the grid is a row. So, one of the most common tasks is iteration through grid setting|getting row specific data. There are two ways to iterate rows in the grid:
In should be noted that there is no fundamental difference between two cell iteration approaches.
This way of iteration has the following characteristics:
<script> for (var i=0; i<grid.getRowsNum(); i++){ // here i - index of the row in the grid do_something_with_row(index); } </script>
This way of iteration has the following characteristics:
<script> grid.forEachRow(function(id){ // function that gets id of the row as an incoming argument // here id - id of the row do_something_with_row(id); }) </script>
Classic cell iterator is the following:
<script> for (var i=0; i<grid.getColumnCount(); i++){ // i - index of the column alert(grid.cells(id,i).getValue()); } </script>
Built-in cell iterator has the following structure:
<script> grid.forEachCell(id,function(c){ alert(c.getValue()); }); </script>
Method forEachCell() takes the following parameters:
You can loop through all rows in some group by
mygrid.forEachRowInGroup(name,function(id){ do_something_with_row(id); });
where name - key-value of group