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,
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.
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 }}}
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 responding. I actually did get this working in my project.
My problem seemed to stem from the fact that I was hiding rows. Basically, I have 2 grids, and when they click on a row in the first grid, I show the rows in the second grid that are applicable, and hide the rows that are not. I was setting row.Element.style.display = "none", which seemed to confuse it. It knew the rows were there, because the childcount was right, but I couldn't access them. I modified my code to change the className on the Element instead, and it seems to work.
Although I might end up having to do a postback anyway, because it takes forever to loop through the grid if there are more than just a few rows.
No. Never did, I figured it must be something wacky about my project, and we just put a workaround in place. Did a full postback rather than javascript like I would have preferred.Let me know if you figure anything out, please. Good luck!
Did you ever find a solution for this? I am having the same problem.
Thanks,
Kerri
I think we need to take a closure look at this issue. Please submit your request @ http://es.infragistics.com/support/default.aspx with our Developer Support Team. If possible, please attach a sample. This way we'll be able to help you more.
Thanks
Think I found a bug? The script I'm running is not triggered from a grid event, it runs after a user action, uses igtbl_getGridById(ClientId).rows.
I do have client side handlers set up for MouseOver, MouseOut, and CellClick. After I saw your post, I tried it again, with the code to set the handlers commented out. Getting the same result.