Exclude certain RadGridView columns's info from being persisted

4 posts, 0 answers
  1. Joe
    Joe avatar
    4 posts
    Member since:
    May 2019

    Posted 06 Aug Link to this post

    Hello,

    I'm trying to exclude some (but not all) RadGridView columns' information from being persisted using PersistenceManager.

    For example, in the below grid, how would I exclude column Info's properties from being persisted based on the column's Header name (assume I've defined CustomPropertyProvider for the grid to persist properties like Width, Header, etc.)?

    <telerik:RadGridView x:Name="TestGrid"
                         telerik:PersistenceManager.StorageId="TestGrid"
                         AutoGenerateColumns="False">
       <telerik:RadGridView.Columns>
          <telerik:GridViewDataColumn Header="Info" DataMemberBinding="{Binding Info}"/>
          <telerik:GridViewDataColumn Header="Data" DataMemberBinding="{Binding Data}"/>
       </telerik:RadGridView.Columns>
    </telerik:RadGridView>

     

    I could use SerializationOptions but I'm not sure what I'd put in the "Expression" field to exclude column "Info" (see below):
    <telerik:PersistenceManager.SerializationOptions>
       <telerik:SerializationMetadataCollection>
          <telerik:PropertyNameMetadata Condition="Except" Expression="??" SearchType="PropertyName" />
       </telerik:SerializationMetadataCollection>
    </telerik:PersistenceManager.SerializationOptions>

     

  2. Drago
    Admin
    Drago avatar
    8 posts

    Posted 08 Aug Link to this post

    Hello Mario,

    To achieve that you can set CustomPropertyProvider. We have a similar example in our SDK repository where we showcase how to use CustomPropertyProvider with GridView.

    To help with your scenario we have created an example project that excludes the "Info" column from being persisted.

    Hope that helps.

    Regards,Dragan G
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  3. Joe
    Joe avatar
    4 posts
    Member since:
    May 2019

    Posted 08 Aug in reply to Drago Link to this post

    Thanks for the code sample.

    Hardcoding the column names I want excluded in the CustomPropertyProvider is not ideal.
    When I register the custom provider as follows:
    ServiceProvider.RegisterPersistenceProvider<ICustomPropertyProvider>(typeof(RadGridView), new GridViewCustomPropertyProvider());
    it will be used for all of my RadGridView tables and having hardcoded rules for one table will affect how I want to manage persistence with other tables (which may also have the same column name "Info" that I don't want excluded in that table). Is there a different option to resolve this problem?

  4. Drago
    Admin
    Drago avatar
    8 posts

    Posted 13 Aug Link to this post

    Hello Mario,

    You can still achieve that with the hardcoded solution.

    Based on the column header name and grid name you can have nested if statements to filter the ones you want to persist.

    I have updated the sample project to showcase how you can do that with two columns having the same names in two different grids.

    Hope that helps.

    Regards,Drago
    Progress Telerik

    Get quickly and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top