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

Exclude certain RadGridView columns's info from being persisted

3 Answers 311 Views
PersistenceFramework
This is a migrated thread and some comments may be shown as answers.
Joe
Top achievements
Rank 1
Joe asked on 06 Aug 2019, 02:52 PM

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>

 

3 Answers, 1 is accepted

Sort by
0
Drago
Telerik team
answered on 08 Aug 2019, 03:42 PM

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 and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Joe
Top achievements
Rank 1
answered on 08 Aug 2019, 04:42 PM

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?

0
Drago
Telerik team
answered on 13 Aug 2019, 11:31 AM

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.
Tags
PersistenceFramework
Asked by
Joe
Top achievements
Rank 1
Answers by
Drago
Telerik team
Joe
Top achievements
Rank 1
Share this question
or