I'm trying to loop through the rows of a grid. My function works fine when not grouped, but something is going awry when grouped.
I'm looping through the top level grid.Rows. On each row I check if row.ChildRowsCount > 0. Which it is on the second iteration.After that I have an alert showing me row.ChildRowsCount and row.getChildRows.length. The first is 4 but the second is 0.I also tried row.getChildRow(0), which is null.
Any help please?
Hi,
The above code worked perfect in my sample. So I was wondering how you are defining the row object. If you are getting the ChildRowsCount > 0 then the above code should work fine. Which client side event is handled for the grid?
Thanks for the quick reply Sarita. I'm not sure I understand what you're saying to do with the band object, it is returning true for IsGrouped, but I still can't access the child rows. Is there some way to do that through the band? See the code below. I'm calling a function for each row in grid.Rows, passing in the row object.
var band = igtbl_getBandById(row.Id);if (band.IsGrouped) {var y;for (y = 0; y < row.ChildRowsCount; y = y + 1) { // loop through child Rows if (row.getChildRow(y)) { alert("Got child row"); // Never see this } else { alert("Row is null!"); // I get this alert several times }}}
You can check if the band is grouped or not and then loop through it. Here is a code snippet:
var row = igtbl_getRowById(cellId);
alert(rowCount);
{
alert(count);
}
This shows how to check if grouping is done. The ChildRowsCount property of Row object returns the number of child rows. If its more than 0 then you can access the child row by it's index.
Hope this helps.