Custom GroupHeaderTemplate with GridViewComboBoxColumn and ItemTemplate

2 posts, 0 answers
  1. Jason Maronge
    Jason Maronge avatar
    321 posts
    Member since:
    Jan 2005

    Posted 05 Oct 2011 Link to this post

    Can anyone tell me how to get the GroupHeaderTemplate to work in my situation. I have the following column in my grid that is a GridViewComboBoxColumn with a ItemTemplate.  The ItemTemplate lets me use the "Lastname, Firstname" to display to the user.  I want that to also be the text in the Group headers.  Can this be done? 

    Thanks

    <telerik:GridViewComboBoxColumn MinWidth="80"  
                                    DataMemberBinding="{Binding ClientId}"
                                    DisplayMemberPath="Lastname"
                                    Header="Dependent of"
                                    SelectedValueMemberPath="Id"
                                    TextWrapping="NoWrap" 
                                    UniqueName="ClientId">
         
        <telerik:GridViewComboBoxColumn.ItemTemplate>
            <DataTemplate>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="{Binding Lastname}" />
                    <TextBlock Text=", " />
                    <TextBlock Text="{Binding Firstname}" />
                </StackPanel>
            </DataTemplate>
        </telerik:GridViewComboBoxColumn.ItemTemplate>
     
        <telerik:GridViewComboBoxColumn.GroupHeaderTemplate>
            <DataTemplate>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="{Binding ???????.Lastname}" />
                    <TextBlock Text=", " />
                    <TextBlock Text="{Binding ???????.Firstname}" />
                </StackPanel>
            </DataTemplate>
        </telerik:GridViewComboBoxColumn.GroupHeaderTemplate>
         
    </telerik:GridViewComboBoxColumn>

    I have the following GroupDescriptor setup:

    <telerik:RadGridView.GroupDescriptors>
        <telerik:GroupDescriptor Member="ClientId" SortDirection="Ascending" DisplayContent="Dependent Of"   />
    </telerik:RadGridView.GroupDescriptors>
  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 06 Oct 2011 Link to this post

    Hello Jason Maronge,

    The DataContext of the group row (and the StackPanel consequently) is GroupViewModel. It contains properties like Group, Column, AggregateResults, etc. What you could try is to bind the TextBlock-s in the GroupHeaderTemplate and based on the values of the properties in the GroupViewModel to return those you want through an IValueConverter for example.
     

    Best wishes,
    Maya
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top