It looks like UltraGrid is re-using row UI including if the row is already expanded. When refreshing with new data, I need to collapse all the rows. There seems to be some performance issue when calling CollapseAll while the grid is populated.
Is there a trick to reset the grid when the DataSource refreshes its data?
Hi,
I'm not sure I understand what you are asking. You asked how to collapse all the rows, but your post already mentions the CollapseAll method and that's how you do it, so I don' know what the question is.
The grid does re-use the UIElement for efficiency. Why is that a problem? Re-using the row elements doesn't have anything to do with the expanded state of the row.
Do you mean that you are binding the grid to a new data source that contains some of the data objects as the old data source did? In that case, the grid will try to re-use the same row specifically so that it does maintain the states like selected and expanded.
In a case like that, you could first set the grid's DataSource to null before you set it to the new DataSource. This will lose the Layout, too, but you can save and restore it.
UltraGridLayout savedLayout = this.ultraGrid1.DisplayLayout.Clone(); this.ultraGrid1.DataSource = null; this.ultraGrid1.DataSource = myNewDataSource; this.ultraGrid1.DisplayLayout.CopyFrom(savedLayout);
I'm loading data to a parent-child grid. The child rows are initially loaded using dummy rows then the true rows are retrieved during the BeforeExpanded event of the row. If I load a new set of data to the grid, any previously expanded rows will stay expanded and will display the dummy rows, so I call CollapseAll after.