Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1170
Incorporating new Column when loading layout from XML
posted

I've got an app that automatically generates columns from a metadata file, then loads the user's saved layout using the LoadFromXml method. I'm having a problem when a new column is added to the metadata. The newly added column appears in the grid after the layout is loaded, but it seems to lose settings that were previously applied; it just breaks in a few strange ways.

I've found a way to mostly get around it, but it's not quite perfect. I follow the advice in this post, instantiating a new DisplayLayout object, load it from xml, and determine which Column objects are new based on their Key values. Then I use these statements to add the new column to the loaded DisplayLayout:

cols[key].Header.VisiblePosition = band.Columns.Count;
band.Columns.Add(cols[key]);

The problem is that while the new column is visible at the end of the grid and it doesn't seem to have its style or bindings broken or anything, the saved order of the columns doesn't get used. Instead it reverts to the original sorting of the columns. I've tested this multiple times by just removing/adding the column declaration from my metadata file. If the unexpected column isn't there, the layout is loaded successfully. My guess is that it's because the Column being added has the same Index value as an existing Column, but this is a read only value. Is there a fix for this, or another solution to the problem of loading a layout when there are new columns?

Parents Reply Children
No Data