Description:
When I refresh data in the grid, all the group rows which were previously expanded are collapsed by the grid. Is it possible to workaround this problem?
Answer:
Yes, it is possible. We have created a sample project which allows you to save/load the groups and master rows expansion state, selection, focused row and position of the focused row. We hope it will be helpful to you.
Note You may wish to store the expanded/selected rows in a file or a database. To implement this feature, please write methods to save and restore row lists of the RefreshHelper class.
See Also:
How to preserve the expanded state of TreeList nodes when refreshing data
Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
I am trying to find an updated example of this for the WPF Grid? Can you help me?
Hi Alexander,
This example is done for WinForms GridControl. I have created a separate ticket ( Provide a WPF version of the A2161 KB article (How to preserve the XtraGrid View state)) on your behalf, so that our support engineers can provide you wish a corresponding sample.
is this still the recommended way to save expansion states? I took a look at the example and the code for saving expansion view info didn't look like it was optimal. Especially this code
for (int i = -1; i > int.MinValue; i--) {
if (!view.IsValidRowHandle(i)) break;
if (view.GetRowExpanded(i)) {
Hello,
It is not clear what issue you have faced when using the RefreshHelper class. Does you have any performance issues?
This code enumerates indexes from -1 to the last valid group row handle. This code operates exactly in the same manner with this while loop:
while (view.IsValidRowHandle(count))
{
//…
count–;
}
If you have any problem with this example, please describe your scenario in greater detail. I am looking forward to your response.
Is there an updated version for 14.1.5?
thanks
Hello,
This example should work properly on this version.
Let us know if you faced any problems using this code sample.
Hi, which example are you refering to? E1466 or E776? By the way what is the main difference between the two? How do I determine which one best suits my needs?
thanks a lot
Hello,
I have checked helper classes for both examples.
The main difference between these examples is that the How to preserve the XtraGrid View state works with only one view, while How to preserve the XtraGrid view state in multi level master/detail can also work with a master-detail grid.
I hope this helps.
Hmmm doesnt work on my end… the expanded row collapses when I refresh the grid…
Hello,
I have created a separate Grid's view state is not saved ticket about this issue. Lets continue our discussion in this thread.
I'm having the same problem.
I'm sorry, can't seem to find a link to the sample project. Can you provide one?
Hello,
A link for a sample project is shown on the right side of the page in the orange box. You can also use the following link: How to preserve the XtraGrid View state
Let me know if you have any further questions.
This code could produce an infinite loop. To produce this, do the following:
It will loop within the FindParentRowHandle routine.
Hello Paul,
Thank you for your feedback. We see that you have posted a similar issue in the How to preserve the XtraGrid View state thread. We will answer you in the E776 thread.
Hello,
is it working at the new version ?
https://github.com/DevExpress-Examples/how-to-preserve-the-xtragrid-view-state-e776/blob/13.1.4%2B/CS/RefreshHelperClass.cs
I´ve tried it with this solution, but the Arraylist always stay empty
Hello,
I've created a separate ticket on your behalf (T904238: How to use the RefreshHelperClass in the latest version). It has been placed in our processing queue and will be answered shortly.
Hello,
which events do I have to use when I want to use the RefreshHelper class with the normal DevExpress Refresh Button?
I use the View.ObjectSpace.Refreshing event to call the RefreshHelper.SaveExpansionViewInfo Method which works fine and stores the expanded rows in the arrayList.
But what event can I use to call the RefreshHelper.LoadExpansionViewInfo?
I have tried View.ObjectSpace.Reloaded event and View.CollectionSource.CollectionChanged event which both did not work.
Thanks for your help!
Hello,
In order not to mix several questions in one thread, I have created a separate ticket on your behalf: T1006659: What event should I use to load the previously saved GridControl's state. We placed it in our processing queue and will process it shortly.