Hi,
I have a scenario where I need to lazy load all of the child rows in my grid. I am lazy loading the underlying data source as well. Initially, I get all of the data for band 0 and then I bind it to the grid. At this point I handle the BeforeRowExpanded event.
In the BeforeRowExpanded event I call to my database and get the child rows for the parent row being expanded. Once I get the data I assign it to the underlying data source via the ListObject property of the row being expanded (e.Row.ListObject). I cast the ListObject as appropriate.
This seems to work ok. At this point I need to refresh the grid so it picks up the changes to the data source. I tried to do it with this (still in the BeforeRowExpanded event):
e.Row.Refresh(RefreshRow.ReloadData, true)
The above doesn't seem to work.
However, if I call the following method it does work:
myGrid.Rows.Refresh(RefreshRow.ReloadData, true)
I believe this refreshes all of the rows in the grid and may be less efficient that just refreshing the one row that I need to. Is that true? Is there a way to just refresh the one row (and its children) that I need?
Thanks!
Steve
Hi Mike,
Thanks for the reply. I tried refreshing the rows of the child band as you suggested, but it still did not work. I thought it would work the way I had it because I set the recursive parameter to true... thinking that would refresh all rows underneath.
Any way, if the process of refreshing all rows is pretty quick I can just do that.
Thanks,
Hi Steve,
In the BeforeRowExpanded event, e.Row refers to the row being expanded. So it seems like that would not work because you don't need to refresh that row, you need to refresh the rows underneath it.
You are correct that rows.Refresh is less efficient since it refreshes the whole grid. But it's really not all that bad - a refresh is a pretty quick process, and it's not like this will be happening in a loop a thousand times. It only happens in response to the user clicking an expansion indicator.
Having said that, if you want to make this as efficient as possible, then try refreshing the child rows collection under the row being expanded, instead of the root-level rows of the grid. To get the child rows, you do something like this:
e.Row.ChildBands[0].Rows.Refresh(RefreshRow.ReloadData, true)
Forgot to mention... I am using a 2006 version of the UltraGrid. It is version 6.2. Not sure if that is the problem, but unfortunately I can't upgrade at the moment.