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
3045
How to collapse all rows before refreshing with new rows?
posted

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?

Parents
  • 469350
    Offline posted

    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);

Reply Children