Welcome to the Xceed Community | Help
Community Search  
More Search Options

How to customized a Column header.

Sort Posts: Previous Next
  •  06-25-2012, 2:04 PM Post no. 32293

    How to customized a Column header.

    Hi,

         I have a requirment that use customized to change the column header of the datagridcontrol.The source data is a Datatable.Datagridcontrol could adjust different datatable(tables have different amount of column,and column name is not fixed).Now I want to customized the column header cell into two parts---a textblock and a combobox.The textblock's text binds column header and the combobox binds a list that contains strings.When the combobox select a item.The textblock's text could change into selecteditem's content.

         Question:

         1.How can I bind the column's header to the textblock's text?

         2.Can I add a filter into this Cell.?

     

         

          <Style TargetType="{x:Type xcdg:ColumnManagerCell}">

                    <Setter Property="Template">

                        <Setter.Value>

                            <ControlTemplate TargetType="{x:Type xcdg:ColumnManagerCell}">

                                <WrapPanel Orientation="Vertical">

                                    <TextBlock Name="HeaderTextBox"></TextBlock>

                                    <ComboBox Name="HeaderComboBox"></ComboBox>

                                </WrapPanel>

                            </ControlTemplate>

                        </Setter.Value>

                    </Setter>

                </Style>

     

          

  •  06-26-2012, 2:53 AM Post no. 32295 in reply to 32293

    Re: How to customized a Column header.

    1. Did you tried using the TitleTemplate of Column object?

    <xcdg:Column FieldName="Name" ShowInColumnChooser="False" Title="Name" IsMainColumn="True" MinWidth="200" Width="0"
                                 TitleTemplate="{StaticResource myTitleTemplate}"/>

     

    2. Your question more generic. In general, you can add filter to any cell. Try using DataGridCollectionViewSource while binding the ItemsSource to the DataGridControl


    Venkatesh Mookkan
  •  06-26-2012, 9:38 AM Post no. 32299 in reply to 32295

    Re: How to customized a Column header.

         Th'x a lot,Venkatesh.But if use TitleTemplate like your code,it couldn't adjust the other datatable(because some table may not have the field  that it's name = Name)..So I think this problem need another method to solve it.Anyway,Thank you.:) 

  •  06-26-2012, 12:32 PM Post no. 32301 in reply to 32299

    Re: How to customized a Column header.

    Hi Vega,

    I am uncertain of what you are trying to achieve. I would need a more detailed explanation of the exact layout and behavior(s) you are looking for in order to provide you with an answer. If you have a screen shot or mock-up showing the look you would like, that would help a lot. Thank you.

     

     


    Fawzi Bablli
    Developer Technical Support
    Xceed Software Inc.
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.