Grid.DisplayLayout.SaveAsXml - PropertyCategory
I have been using PropertyCategory.All but that is producing 2 issues that I would like resolved:
When I add or remove a column in the code, it still shows the old columns in ShowColumnChooser. I would like to retain the visible column position and list of visible columns from ShowColumnChooser but I would like to have any new columns / bands that are added or removed to show up in the ShowColumnChooser. So basically, I want to retain the existing column information (size, position, visiblility, etc.) but also get the new information (I wouldn't mind if the new columns were hidden but they do show up under the column chooser for the user to add).
I also don't want to retain appearances (aka I want the information like background color to come from the code).
What PropertyCategory do I need to use?
haessd said: I added column 5 and set its appearance in the application and its appearance however when running the application the new column does not match the code. I would like newly added items to the datasource to automatically show up with correct appearance.
What's happening here is that you are losing the entire Layout of the grid at run-time. By loading the layout inside InitializeLayout, the original Layout is being reset before the new layout is loaded. Essentially, you are trying to merge the new layout into the existing one - there's no way to do that.
What I would do is load the layout, and then set the Appearances you want on Column 5 (and any other columns) in code, in the InitializeLayout event, instead of doing it at design-time.
haessd said:I also removed Column UBx - so I would like the column to disappear if it isn't found in the code.
There's no way that the grid could know that you don't want this column any more. It exists in the layout, which you are loading, so it gets loaded into the grid.
You could, of course, remove it from the grid after it is loaded. Or, if you want to be slightly more efficient about it, you could load the Layout from the file into an UltraGridLayout variable instead of directly into the grid. Then you could modify the layout first, before you load it into the grid (via grid.DisplayLayout.CopyFrom).
haessd said:I also changed the appearance for UnboundColumn1 - I would like to apply the appearance in the application over the appearance in the XML file.
Again, the way to do this is by setting the appearance at run-time, after you have already loaded the layout.
haessd said:Is there an easy way of applying everything from XML file excluding the appearance properties, Cell Behavior (aka click action, activation, etc.). I want Cell Width, Cell Position, Cell Visibility, Sort, Filter, etc. to come from the XML file for instance.
No, there is no way to do this.
Open attached zip file - Text.xml file was a saved layout and applied layout (put it into c:\temp\) prior to change to my datasource / code. I added column 5 and set its appearance in the application and its appearance however when running the application the new column does not match the code. I would like newly added items to the datasource to automatically show up with correct appearance.
I also removed Column UBx - so I would like the column to disappear if it isn't found in the code.
I also changed the appearance for UnboundColumn1 - I would like to apply the appearance in the application over the appearance in the XML file.
Is there an easy way of applying everything from XML file excluding the appearance properties, Cell Behavior (aka click action, activation, etc.). I want Cell Width, Cell Position, Cell Visibility, Sort, Filter, etc. to come from the XML file for instance.
When you reply, go to the Options tab and you can attach a file.
How do I post a sample project???
Hi,
I am unable to reproduce any of the behavior you describe here.
The ColumnChooser displays the header text (if there is any), not the column's Key.
Can you post a small sample project demonstrating this behavior?
haessd said:I would like to have the following to come from code (header, cell background color, cell click action, cell activation, cell style, cell multiline, ...). I would like the following to come from the XML file (cell position, cell width, sorting, etc.).
It sounds like you need to load the layout and then adjust the appearances you want in code after it is loaded.