Hi,
I am building the layout (ordered columns, sorting, grouping, and summaries) of a grid strictly by loading a layout (from stream).
What I want to accomplish is to specify a DataTemplateSelector for the columns' headers. My strong preference is to do this from within the stream.
The things that I have tried, which have not worked are:
- Setting the GridControl.ColumnGeneratorTemplateSelector explicitly in xaml. This declaration has worked in the past before I switched the column generation to using layouts.
- I have tried including a "property" element in the layout xml for the column. Setting it with something like:
property.Add(CreateProperty("HeaderTemplateSelector", "{StaticResource ColumnTemplateSelector}"));
(Assume that property and CreateProperty are models and helper methods within my code, and that they work for other properties like "FieldName", "VisibleIndex", "Width", etc)
Can you provide some information if it's possible to set the HeaderTemplate and/or the HeaderTemplateSelector for a column that has been generated from a layout?
Thanks,
Jayson
Hello Jayson,
Thank you for your question. We do not provide a way to save a column's EditSettings/DisplayTemplate/EditTemplate/CellTemplate in the layout. We believe there is no need in this. At the moment, our serializer is not able to parse/format templates/settings. We made several attempts to implement this but encountered different problems. So, we simply declined this idea. When every column has a unique name and is present in the GridControl.Columns collection, a necessary template/setting editor will be loaded automatically. In your scenario, you do not have a column in GridControl until a custom layout is applied.
We can offer two solutions to you. The first and simplest solution is to place all columns in your grid and assign the Visible property to False for columns that you want to hide. Create several layouts and assign the necessary one.
The other solution is suitable for those who does not look for a soft option… Handle the GridControl.Columns.CollectionChanged event when the necessary column is added and assign a necessary template. Keep your templates in Window.Resources.
Let me know if you need further clarification.
Thank you, Marina