We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Persist and restore grid's state

Hi, 

We have a sfDataGrid in a tabview, embedded in another stateful widget. Grid is sorted, maybe filtered, and scrolled in a row. We move in another tab (  hiding the tab where the grid was created). 
Returning back (changing the visibility of the tab),  we update the  GridSource, if a  new object have been added  or updated in the source data,
The question is how we can return the Grid in its filtered/sorted state and previous row position ? 
How to persist its state ?
We can't find a way to keep the container widget with the Grid without rebuild, after we hide the tab.

Thank you


2 Replies

ST Stefan Tsalapatis November 12, 2022 08:44 PM

I found how to keep the tab  (and the Grid inside) when the visibility changes, using in the parent widget

AutomaticKeepAliveClientMixin and  wantKeepAlive.
But I'm interested in general  how to persist the Grid's state



TP Tamilarasan Paranthaman Syncfusion Team November 14, 2022 08:57 AM

Based on your requirement, if you switch to the other tab view from the DataGrid tab view, then the existing DataGrid state would be disposed of. Again, you switch to the DataGrid tab the state would be initialized again. So, you would lose the existing sort/filtering state. As you mentioned in the query, you can maintain using the AutomaticKeepAliveClientMixin and wantKeepAlive properties. Also, DataGrid doesn't have any other default support for maintaining the DataGrid State.


Loader.
Live Chat Icon For mobile
Up arrow icon