This is a migrated thread and some comments may be shown as answers.

Custom GroupHeaderTemplate with GridViewComboBoxColumn and ItemTemplate

1 Answer 164 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jason Maronge
Top achievements
Rank 1
Jason Maronge asked on 05 Oct 2011, 10:52 PM
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>

1 Answer, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 06 Oct 2011, 06:51 AM
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 >>

Tags
GridView
Asked by
Jason Maronge
Top achievements
Rank 1
Answers by
Maya
Telerik team
Share this question
or