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

Multiple settings in one file

3 Answers 47 Views
Persistence Framework
This is a migrated thread and some comments may be shown as answers.
Tom
Top achievements
Rank 1
Tom asked on 03 Sep 2013, 03:06 PM
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() });
        }

3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 09 Sep 2013, 11:50 AM
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.
0
Tom
Top achievements
Rank 1
answered on 10 Oct 2013, 04:22 PM
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.
0
Daniel
Telerik team
answered on 15 Oct 2013, 12:14 PM
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.
Tags
Persistence Framework
Asked by
Tom
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Tom
Top achievements
Rank 1
Share this question
or