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

Best Practices: Removing Columns from Grid

1 Answer 183 Views
PersistenceFramework
This is a migrated thread and some comments may be shown as answers.
Robin
Top achievements
Rank 1
Robin asked on 21 Aug 2014, 07:03 AM
I have been using Persistence Framework to save the state of RadGridViews. The RadGridViews have a column chooser which enables the user to change the visible columns (IsVisible=true/false). The WPF program saves the state of grids on exit, and loads them when the program starts. This works very well.

However, recently, as part of an update to the software, I had to remove a column definition from the XAML and the Data Model. I noticed that when the program was loaded again, the column still appears (because I had chosen it in my grid) but the values are all blank.

My question is:
Are there any best practices for using the Persistence Framework with new releases of my software? For example, a way to force an update/automatically remove the persisted data for a particular grid that changes?

1 Answer, 1 is accepted

Sort by
0
Zarko
Telerik team
answered on 22 Aug 2014, 02:55 PM
Hello Robin,
There's no one unified way to do this because it all depends on your scenario - where do you keep the saved data, is it distributed to users, what is your implementation and etc. but there are two possible approaches:
- override the saved data if possible - don't load the old data and instead override it with saved data from your new grid view
- this depends on your implementation but you could add some logic in the CustomPropertyProvider so that it doesn't load a specific column e.g.:
public void RestoreValue(CustomPropertyInfo customPropertyInfo, object context, object value)
{
   ...
        case "Columns":
            {
                List<ColumnSetting> columnProxies = value as List<ColumnSetting>;
 
                foreach (ColumnSetting proxy in columnProxies)
                {
                    if(proxy.Header.Equals("IDontWantThisColumn") continue;
                    ...
                }
            }
            break;
   ...
I hope I was able to help you and if you have more questions please feel free to ask.

Regards,
Zarko
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Evangelista
Top achievements
Rank 1
Iron
commented on 12 Apr 2022, 05:31 PM

Hi,

This also happened with an update to my software, but we added a column and it didn't show up.

Is there a new approach?

Dilyan Traykov
Telerik team
commented on 15 Apr 2022, 01:38 PM

As mentioned by Zarko, there is no unified approach for handling such a scenario and this needs to performed per case.

In this case, you may add an additional proxy in the list of ColumnSetting instances in the RestoreValue method to ensure that the newly-added column is shown.

Tags
PersistenceFramework
Asked by
Robin
Top achievements
Rank 1
Answers by
Zarko
Telerik team
Share this question
or