This is a migrated thread and some comments may be shown as answers.

PresistenceFramework not save groups!

9 Answers 178 Views
PersistenceFramework
This is a migrated thread and some comments may be shown as answers.
Paweł
Top achievements
Rank 1
Paweł asked on 14 Aug 2012, 09:07 AM
Hello!

We are developing an application using Telerik Controls. When we stand in front of use Presitence Framework, we found that this is not saving groups in RadGridViews

We are using MVVM Light, all RadGridViews ItemSource are bound to ViewModels, all columns are autogenerated.

Saving grouping state is very important in our project - what could we have done wrong?

9 Answers, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 17 Aug 2012, 12:29 PM
Hi Paweł,

In order to persist the RadGridView control, you need to create a CustomPropertyProvider. I attached a sample solution demonstrating a GridViewCustomPropertyProvider that saves the filters, sorting and grouping in the GridView control. Please let me know if it works for you.

Regards,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Paweł
Top achievements
Rank 1
answered on 21 Aug 2012, 10:12 AM
Ok, it is working fine (after few mods), but how can I save that stream to isolated storage?
Kind regards!
0
Tina Stancheva
Telerik team
answered on 21 Aug 2012, 12:13 PM
Hi Paweł,

In order to save the settings of the RadGridView in an isolated storage, you need to define the PersistenceManager.StorageId attached property in the RadGridView definition:
<telerik:RadGridView x:Name="gridView" telerik:PersistenceManager.StorageId="xRadGridView"
        Grid.Column="1"
        ItemsSource="{Binding}" />

Then in you can implement the following OnSave() and OnLoad() methods:
private void OnSave(object sender, System.Windows.RoutedEventArgs e)
{
    IsolatedStorageProvider isoStorageProvider = new IsolatedStorageProvider();
    isoStorageProvider.SaveToStorage();
}
 
private void OnLoad(object sender, System.Windows.RoutedEventArgs e)
{
    IsolatedStorageProvider isoStorageProvider = new IsolatedStorageProvider();
    isoStorageProvider.LoadFromStorage();
}

You can find more information in our online documentation. Let us know if it helps.

Regards,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Paweł
Top achievements
Rank 1
answered on 21 Aug 2012, 01:46 PM
It is not saving whole data - i.e. expanded groups, selected rows
0
Tina Stancheva
Telerik team
answered on 21 Aug 2012, 04:43 PM
Hi Paweł,

As the RadPersistenceFramework cannot save the settings of the RadGridView out-of-the-box, we've implemented the approach with defining custom property provider. The purpose of the property providers is to allow you to define which properties of complex controls like the RadGridView should be persisted. The GridViewCustomPropertyProvider defined in the sample solution I sent you is a basic implementation demonstrating how to persist the Columns UniqueName, Header, Width and DisplayOrder as well as the filters, sortings and the groupings implemented in the RadGridView. This is why you'll need to extend the class to save the other properties that your application should persist.

Basically  the GetCustomProperties method should return a list of all RadGridView persisted properties. The ProvideValue() method should implement the logic that saves the properties and the RestoreValue() method should include logic that will restore the saved values.

Let us know if you encounter any issues while extending the GridViewCustomPropertyProvider.

Regards,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Paweł
Top achievements
Rank 1
answered on 22 Aug 2012, 08:49 AM
I've implemented it and it works fine, but is there any oportunity to write GridViewCustomPropertyProvider results into isolated storage?
0
Tina Stancheva
Telerik team
answered on 22 Aug 2012, 08:55 AM
Hello Paweł,

The CustomPropertyProvider defines only the logic that the PersistenceFramework should use when saving a set of properties - in your case it controls which RadGridView properties to be saved and how. Where to save the properties is determined by the PersistenceFramework saving approach you've chosen. This is why as long as you use the IsolatedStorageProvider.SaveToStorage() method, the properties defined in the GridViewCustomPropertyProvider will be saved in the isolated storage.

Regards,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Paweł
Top achievements
Rank 1
answered on 22 Aug 2012, 10:29 AM
How to persist actualy expanded groups and selected row in GridViewCustomPropertyProvider?
All RadGridViews data persisting well, but only SelectedItems persist for only one RadGridView in projects. I've been debugging it, but in some RadGridViews loading data providing correct model, but couldn't find it in gridView.Items, other cases just do not load any "SelectedItems" properties, although it has been saved.
0
Accepted
Tina Stancheva
Telerik team
answered on 27 Aug 2012, 11:26 AM
Hi Paweł,

I attached a sample solution demonstrating how to extend the GridViewCustomPropertyProvider to persist the selected rows as well as the expanded rows. I defined a Hiererchical RadGridView to demonstrate how you can persist the settings of a nested GridView as well. 

Basically it's important to note that you need a logic that keeps track of the selected and expanded rows. For that purpose we've defined a helper class that attached event handlers to the RadGridView  RowLoadedRowIsExpandedChanged and SelectionChanged. These events track the selected and expanded rows and based on a generated id, they populate two collections - with the selected and expanded ids. This helper class is then used to provide and restore the selected and expanded rows in the GridViewCustomPropertyProvider  so that the PersistenceFramework is aware of them and can properly save and load them.

Please examine the solution and let me know if it helps.

All the best,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
PersistenceFramework
Asked by
Paweł
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Paweł
Top achievements
Rank 1
Share this question
or