Multiple settings in one file

4 posts, 0 answers
  1. Tom
    Tom avatar
    10 posts
    Member since:
    May 2013

    Posted 03 Sep 2013 Link to this post

    I would like to store different RadGrids' settings in one storage provider key file per user. i.e. all settings throughout the application for a user would be in one file. I am using the custom grid settings provider as per your demo and using the loadcustomsettings and savecustomsettings events to manage the custom settings. However when I add a setting for a grid it overwrites the entire file deleting any other settings that are added from other pages. I was hoping that using customsettings.add would just add/update that setting and leave the others alone. i.e. it would only affect the controlsetting with the provided name.

    Here is the code I have for the persistence events. The same code exists on all the pages that have grids except the name when adding the settings is different (e.g. clinics, users, patients etc).

    void PersistManager_LoadCustomSettings(object sender, PersistenceManagerLoadStateEventArgs e)
            {
                GridSettingsPersister loadPersister = new GridSettingsPersister(RadGrid1);
                string settings = (string)e.CustomSettings.ControlSettings[0].Value;
                loadPersister.LoadSettings(settings);
                RadGrid1.Rebind();
            }
     
            void PersistManager_SaveCustomSettings(object sender, PersistenceManagerSaveStateEventArgs e)
            {
                GridSettingsPersister savePersister = new GridSettingsPersister(RadGrid1);
                e.CustomSettings.Add(new Telerik.Web.UI.ControlSetting() { Name = "clinics", Value = savePersister.SaveSettings() });
            }
  2. Daniel
    Admin
    Daniel avatar
    4943 posts

    Posted 09 Sep 2013 Link to this post

    Hello Tom,

    If I'm not missing something, you are using a combination of the GridSettingsPersister class and the PersistenceFramework. Is this so?
    That said, I tried to reproduce the problem on my end, but unfortunately to no avail. Please examine the attached demo and let me know if I'm leaving something out.

    Regards,
    Daniel
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Tom
    Tom avatar
    10 posts
    Member since:
    May 2013

    Posted 10 Oct 2013 Link to this post

    Thank you for the sample. This works fine but I need to be able to store data on different pages...that is where it overwrites it. Say I have 10 pages with a grid on each page. I want the user to save the settings for each grid. Will I need to create a file for each one? I was hoping I could have one file per logged in user that has all of their settings.
  5. Daniel
    Admin
    Daniel avatar
    4943 posts

    Posted 15 Oct 2013 Link to this post

    Hello Tom,

    Please try specifying different IDs for the persisted controls and see if the problem still persists.
    Furthermore you have almost complete freedom over the storage provider. You can create your own provider that puts all data in a single or multiple files or databases.

    Regards,
    Daniel
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top