Hi,
In our application we allow users to save customizations they have made to a grid to a database. The issue we have is that the fields in that grid are always changing and whenever a field is dropped from the field layout definition this then breaks all the saved customizations. We either have to manually go in and tweak all the XML in the database or we have to ask the users to create their saved view again. As you can imagine, neither is a particularly satisfying solution.
Is there a way we can make LoadCustomizations not fall over when a column no longer exists? And if not, can this be raised as a feature request to allow the method to ignore missing fields.
(Let me know if you require a sample attachment but it is quite simple to recreate yourself. Create a grid with two fields and extend the column width of both. Save the customization xml. Then delete one of the field definitions, reload the app and attempt to load the customization xml and it will not apply the column width to the column that does still exist).
thanks,
Karan
HI,
I am just following up on this forum thread.
Please let me know if I can provide further assistance.
Sincerely, Matt Developer Support Engineer
HI ,
Instead of removing the field, you could change its visibility to collapsed.
Here is a code snippet
xamDataGrid1.FieldLayouts[0].Fields[0].Visibility = System.Windows.Visibility.Collapsed;
I made this change to the sample and it worked.
I;ve attached the sample.
Sincerely,Matt
Hi Matt,
Thanks for your help. I tried the sample project and can see it works in there but unfortunately when I tried to use the workaround in our project it did not work and instead the grid would just go blank (all column headers removed). The difference is that in our project we specify the fieldlayout in xaml (because we apply certain styles to columns and use value converters etc.).
Attaching a modified version of your sample project which has the grid xaml definition like ours and you can see the issue. Any chance there is a workaround for this scenario?
I will create a feature request for this issue.
I am attaching a sample project that contains a workaround for this issue.