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

display parent row info in child table

2 Answers 286 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 1
Dan asked on 11 Apr 2013, 10:16 PM
if you setup hierarchy and you want bind / display info in the child grid for the parent row it belongs to..in the xaml/bing how can you get reference to parent row from the child as part of databinding...

<telerik:RadGridView Name="gridView" ItemsSource="{Binding Person}">
    <telerik:RadGridView.ChildTableDefinitions>
                <telerik:GridViewTableDefinition />
    </telerik:RadGridView.ChildTableDefinitions>
    <telerik:RadGridView.HierarchyChildTemplate>
        <DataTemplate>
            <StackPanel>
            <TextBlock Text="{Binding ParentRow.SomeProperty}"/>
            <telerik:RadGridView ItemsSource="{Binding Children}" Name="childGrid" ShowGroupPanel="False" />
            </StackPanel>
        </DataTemplate>
    </telerik:RadGridView.HierarchyChildTemplate>
</telerik:RadGridView>

2 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 15 Apr 2013, 01:07 PM
Hello,

Please note that the DataContext for the hierarchy is the item bound to the parent row.
You can display the parent row's info like so:

<telerik:RadGridView.HierarchyChildTemplate>
    <DataTemplate>
        <StackPanel>
        <TextBlock Text="{Binding SomeProperty}"/>
        <telerik:RadGridView ItemsSource="{Binding Children}" Name="childGrid" ShowGroupPanel="False" />
        </StackPanel>
    </DataTemplate>
</telerik:RadGridView.HierarchyChildTemplate>


Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Dan
Top achievements
Rank 1
answered on 15 Apr 2013, 07:26 PM
Duh...not sure why I wasn't thinking that first...I'll chalk it up to a long day, lol
Tags
GridView
Asked by
Dan
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Dan
Top achievements
Rank 1
Share this question
or