Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
490
Refresh data on a single grid row
posted

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

Parents
  • 469350
    Offline posted

    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)

Reply Children
No Data