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

GroupHeaderTemplate does not support RelativeSource={RelativeSource AncestorType=telerik:RadGridView}}"

2 Answers 61 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Bryce
Top achievements
Rank 1
Bryce asked on 17 Jul 2012, 07:16 PM
Hi,

I have a group header template and I want to find the ID of the the parent data context. In SL5, you can do this:

<TextBlock Text="{Binding DataContext.ID, RelativeSource={RelativeSource AncestorType=telerik:RadGridView}}"/>
 
When I put this as a celltemplate in the column in the grid, it is able to get the ID, however when it is put in the groupheadertemplate, it does not get the ID.

I know the it is being bound to is the GroupViewModel, but its namespace is: Telerik.Windows.Controls.GridView so you would think you would be able to get the ID of the DataContext the RadGridView is within.
 
Any one know a way around this?

Thanks,

Bryce                

2 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 18 Jul 2012, 06:18 AM
Hello Bryce,

I would suggest you to expose the DataContext as a StaticResource. Then use it for the Binding, for example:
<TextBlock Text="{Binding ID, Source={StaticResource MyDataContext}}"/> 

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Fredy
Top achievements
Rank 1
answered on 25 Nov 2012, 05:51 AM
Hi, How can show the name of month in the GroupHeaderTemplate?

I tried this:

<telerik:GridViewDataColumn DataMemberBinding="{Binding Date, StringFormat='MMM dd yyyy, ddd'}">
                                    <telerik:GridViewDataColumn.AggregateFunctions>
                                        <telerik:CountFunction
                                        Caption="Days: "/>
                                    </telerik:GridViewDataColumn.AggregateFunctions>
                                </telerik:GridViewDataColumn>
                                <telerik:GridViewDataColumn DataMemberBinding="{Binding Month}" IsVisible="False">
                                    <telerik:GridViewDataColumn.GroupHeaderTemplate>
                                        <DataTemplate>
                                            <StackPanel Orientation="Horizontal">
                                                <TextBlock Text="{Binding Date, StringFormat='MMMM'}" />
                                            </StackPanel>
                                        </DataTemplate>
                                    </telerik:GridViewDataColumn.GroupHeaderTemplate>
                                </telerik:GridViewDataColumn>

<telerik:RadGridView.GroupDescriptors>
                                <telerik:GroupDescriptor Member="Year" SortDirection="Descending"/>
                                <telerik:GroupDescriptor Member="Month" SortDirection="Descending"/>
                            </telerik:RadGridView.GroupDescriptors>

Tks!!! :)


Tags
GridView
Asked by
Bryce
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Fredy
Top achievements
Rank 1
Share this question
or