not restoring layout as saved

16 posts, 1 answers
  1. Scott
    Scott avatar
    66 posts
    Member since:
    Nov 2009

    Posted 12 Aug 2011 Link to this post

    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?

  2. Answer
    Alex Fidanov
    Admin
    Alex Fidanov avatar
    636 posts

    Posted 15 Aug 2011 Link to this post

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

  3. DevCraft banner
  4. Scott
    Scott avatar
    66 posts
    Member since:
    Nov 2009

    Posted 15 Aug 2011 Link to this post

    It is working thanks. What other Telerik controls do I need to create a custom property provider for?
  5. Alex Fidanov
    Admin
    Alex Fidanov avatar
    636 posts

    Posted 17 Aug 2011 Link to this post

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

  6. Marc
    Marc avatar
    66 posts
    Member since:
    Jul 2010

    Posted 13 Sep 2011 Link to this post

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


  7. Alex Fidanov
    Admin
    Alex Fidanov avatar
    636 posts

    Posted 16 Sep 2011 Link to this post

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

  8. Marc
    Marc avatar
    66 posts
    Member since:
    Jul 2010

    Posted 16 Sep 2011 Link to this post

    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?
  9. Alex Fidanov
    Admin
    Alex Fidanov avatar
    636 posts

    Posted 16 Sep 2011 Link to this post

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

  10. Louis
    Louis avatar
    42 posts
    Member since:
    Jun 2011

    Posted 26 Sep 2011 Link to this post

    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.
  11. Marc
    Marc avatar
    66 posts
    Member since:
    Jul 2010

    Posted 27 Sep 2011 Link to this post

    Agreed. Please provide a demo of persistence framework using isolated storage with radgridview.
  12. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 29 Sep 2011 Link to this post

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

  13. Muhammad
    Muhammad avatar
    3 posts
    Member since:
    Jan 2012

    Posted 11 Jan 2012 Link to this post

    Hi,
    how can i make it to work on childwindow loaded and closed.rather to work on application start and exit.
    best regards
    shabbir
  14. Muhammad
    Muhammad avatar
    3 posts
    Member since:
    Jan 2012

    Posted 12 Jan 2012 Link to this post

    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
  15. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 16 Jan 2012 Link to this post

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

  16. jeroentjeathome
    jeroentjeathome avatar
    2 posts
    Member since:
    Aug 2015

    Posted 12 Aug 2015 Link to this post

    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. 

  17. jeroentjeathome
    jeroentjeathome avatar
    2 posts
    Member since:
    Aug 2015

    Posted 12 Aug 2015 Link to this post

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

     

Back to Top
DevCraft banner