Ticket Q395352
Visible to All Users

Specifying a HeaderTemplateSelector for columns restored from a Layout

created 13 years ago

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:

  1. Setting the GridControl.ColumnGeneratorTemplateSelector explicitly in xaml. This declaration has worked in the past before I switched the column generation to using layouts.
  2. 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
Comments (1)
DevExpress Support Team 13 years ago

    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

    Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

    Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.