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

not restoring layout as saved

15 Answers 256 Views
PersistenceFramework
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 12 Aug 2011, 08:16 PM
I created a small sample application that has a RadDocking and RadTreeView control. I moved the docking panes around and save the layout using:
IsolatedStorageProvider isoProvider = new IsolatedStorageProvider();
isoProvider.SaveToStorage();
I restart the application and load the storage information and the RadDocking control is all incorrect. Please see attached before and after images.
Here is my test application: http://dl.dropbox.com/u/15525269/TelerikPersistence.zip

Am I using the telerik:PersistenceManager.StorageId attribute incorrectly?

15 Answers, 1 is accepted

Sort by
0
Accepted
Alex Fidanov
Telerik team
answered on 15 Aug 2011, 08:14 AM
Hello Scott,

Thank you for providing this project. To be persisted, the RadDocking control needs a custom property provider, which you can find an example with in our online demos here. After registering this provider, you will be able to save and load the layout and the contents of the panes of the docking control correctly. Please let me know if you have questions on this.

Best wishes,
Alex Fidanov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
Scott
Top achievements
Rank 1
answered on 15 Aug 2011, 05:56 PM
It is working thanks. What other Telerik controls do I need to create a custom property provider for?
0
Alex Fidanov
Telerik team
answered on 17 Aug 2011, 09:49 AM
Hello Scott,

Currently, the GridView and Docking controls only have implemented custom property providers, which you can find in the online demos. They are more complex than the rest of the controls and they need custom serialization.

Please note that you can implement and register your own custom providers for any control (or other custom controls), if you need to customize or plug into the serialization process of the PersistenceFramework.

Greetings,
Alex Fidanov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
Marc
Top achievements
Rank 1
answered on 13 Sep 2011, 05:07 PM
Is there an example of persisting gridview settings in isolated storage?


Edit. The following seems to work (loads users layout on page load, allows them to save layout with button). Is there a better way?


public SomeView()
{
    InitializeComponent();
    ServiceProvider.RegisterPersistenceProvider<ICustomPropertyProvider>(typeof(RadGridView), new GridViewCustomPropertyProvider());
        LoadDefaultView();
}
private void SaveViewButtonClick(object sender, RoutedEventArgs e)
{
        var manager = new PersistenceManager();
        this._stream = manager.Save(this.SomeGridView);
        var reader = new StreamReader(_stream);
        string text = reader.ReadToEnd();
        SaveIsoData(text, "SomeGridView");
        MessageBox.Show("Layout saved.");
}
private static void SaveIsoData(string data, string fileName)
{                using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
        {
            using (var isfs = new IsolatedStorageFileStream(fileName, FileMode.Create, isf))
            {
                using (var sw = new StreamWriter(isfs))
                {
                    sw.Write(data);
                    sw.Close();
                }
            }
        }
    }
private void LoadDefaultView()
{
        var manager = new PersistenceManager();
        byte[] byteArray = Encoding.UTF8.GetBytes(LoadIsoData("SomeGridView"));
        Stream stream = new MemoryStream(byteArray);
        stream.Position = 0L;
        manager.Load(this.SomeGridView, stream);
}
private static string LoadIsoData(string fileName)
{
    string data = String.Empty;
        using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
        {
            using (var isfs = new IsolatedStorageFileStream(fileName, FileMode.Open, isf))
            {
                using (var sr = new StreamReader(isfs))
                {
                    string lineOfData = String.Empty;
                    while ((lineOfData = sr.ReadLine()) != null)
                        data += lineOfData;
                }
            }
        }
    return data;
}


0
Alex Fidanov
Telerik team
answered on 16 Sep 2011, 11:23 AM
Hi Marc,

Have you looked at the IsolatedStorageProvider class that provides this functionality out of the box?

Kind regards,
Alex Fidanov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Marc
Top achievements
Rank 1
answered on 16 Sep 2011, 03:06 PM
Yes, it was persisting other controls, but not the radgridview controls. I see you use a treeview instead of a gridview in the documentation. Should they work the same?
0
Alex Fidanov
Telerik team
answered on 16 Sep 2011, 04:41 PM
Hi Marc,

The IsolatedStorageProvider internally uses a PersistenceManager instance, so whatever you can do with the persistence manager class, the isolated storage provider can do as well. What it does is just to save the serialization stream in the isolated storage.

All the best,
Alex Fidanov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Louis
Top achievements
Rank 1
Iron
Iron
Iron
answered on 26 Sep 2011, 04:25 PM
Hello Telerik,

After few hours, it'not able to use PF and RadGridView in a normal context (save and load automatically).

Can you provide me a full complete example with PF AND RadGridView using IsolatedStorage (not STREAM).  More, with no buttons LOAD and SAVE because I don't want my users push some kind of button to save and load.  I need to load the PF when the silverlight page appear on the screen and save when the user go to another page.

The demo don't show any information.
0
Marc
Top achievements
Rank 1
answered on 27 Sep 2011, 03:09 PM
Agreed. Please provide a demo of persistence framework using isolated storage with radgridview.
0
Tina Stancheva
Telerik team
answered on 29 Sep 2011, 03:49 PM
Hi guys,

I attached a sample project to get you started on your task. Please examine it and let us know if it works for you.

Also, please keep in mind that the data saved in the isolated storage, should be loaded only after the RadGridView.Columns are generated.

Best wishes,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Muhammad
Top achievements
Rank 1
answered on 11 Jan 2012, 05:23 PM
Hi,
how can i make it to work on childwindow loaded and closed.rather to work on application start and exit.
best regards
shabbir
0
Muhammad
Top achievements
Rank 1
answered on 12 Jan 2012, 10:47 AM
i tried to integrate your code into my solution,i can run your sample project and working really well but i need to integrate into my solution and i am able to integrate but its not loading or saving anything can you please tell me any particular thing need to do.
with regards
shab
0
Tina Stancheva
Telerik team
answered on 16 Jan 2012, 02:45 PM
Hi Shabbir,

I am not sure why you have troubles integrating our code into your solution. Can you please elaborate more on the issues you've encountered? Are there any exceptions raised?

In the meantime I attached a modified version of the sample application, where the RadGridView is hosted in a ChildWindow and the Persistence framework save the UI settings of the GridView when the ChildWindow is closed and loads them again when the RadGridView is loaded. I hope this solution will help.

Kind regards,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
jeroentjeathome
Top achievements
Rank 1
answered on 12 Aug 2015, 05:02 PM

I have downloaded a trial and have noticed that when I use

 IsolatedStorageProvider isoProvider = new IsolatedStorageProvider();

isoProvider.SaveToStorage();

and then the next session do a Load

IsolatedStorageProvider iso = new IsolatedStorageProvider();
iso.LoadFromStorage();   

 the layout is nicely restored. However: some of the grid columns are dropdown lists and databound. When I have done the LoadFromStorage the databinding of the viewmodel is gone, and the list is empty. Also recreating the viewmodel does not work. 

0
jeroentjeathome
Top achievements
Rank 1
answered on 12 Aug 2015, 05:37 PM

Figured it out myself. Registering the ICustomPropertyProvider helps a lot :-)

 

Tags
PersistenceFramework
Asked by
Scott
Top achievements
Rank 1
Answers by
Alex Fidanov
Telerik team
Scott
Top achievements
Rank 1
Marc
Top achievements
Rank 1
Louis
Top achievements
Rank 1
Iron
Iron
Iron
Tina Stancheva
Telerik team
Muhammad
Top achievements
Rank 1
jeroentjeathome
Top achievements
Rank 1
Share this question
or