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?
Hi,
I'm having trouble understanding your questions.
If you add a column to the grid, the ColumnChooser should show those columns. If they are not showing up, then something is wrong. There is a property on the column called ExcludeFromColumnChooser. If you set this property to true, then the column is explicitly not shown in the ColumnChooser. But as long as you do not set this property, the column should display. If it's not, then it's a bug.
haessd said:I also don't want to retain appearances (aka I want the information like background color to come from the code).
What appearances are you referring to? All of them?
I don't beleive it's possible to load a layout without applying the appearances. You can choose not to save the AppearancesCollection, but that only help if all of your appearances are coming from that collection.
>> If you add a column to the grid, the ColumnChooser should show those columns. If they are not showing up, then something is wrong. There is a property on the column called ExcludeFromColumnChooser. If you set this property to true, then the column is explicitly not shown in the ColumnChooser. But as long as you do not set this property, the column should display. If it's not, then it's a bug.
You are correct about missing columns showing up - Although the appearance of the missing columns is incorrect - for instance I add a new column with Key = "REPLACEABLE_PARTS' and Header = "Parts", when the application is ran, it shows "REPLACEABLE_PARTS" for the Header which is incorrect. I would like the appearance of new columns to match the code.
Additionally: Minor thing - I did get a crash (10.3 of Net Advantage) when I renamed a hidden unbound column (renamed the Key) and referenced the renamed hidden column in code. The LoadFromXml I guess didn't rename the key of the column (I guess because it was hidden). I think this is what caused the crash but I am not too concerned about this - only happened once since it won't happen very frequently.
>> What appearances are you referring to? All of them?
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.).
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???
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.