Best Practices: Removing Columns from Grid

2 posts, 0 answers
  1. Robin
    Robin avatar
    3 posts
    Member since:
    Jun 2014

    Posted 21 Aug 2014 Link to this post

    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?

  2. Zarko
    Admin
    Zarko avatar
    755 posts

    Posted 22 Aug 2014 Link to this post

    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.
     
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top