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

Three level hierarchy support

1 Answer 105 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Farhan
Top achievements
Rank 1
Farhan asked on 08 Mar 2011, 08:46 PM
Hi,

I am looking to implement a three level hierarchy whereby the child grids are determined on the run time. For example if we select an option from a combo box present on the parent grid, it will create a child grid. Similarly we could repeat the same scenario for the child grid as well. I am looking into doing this by creating hierarchical templates for both the parent and the child:

<telerik:RadGridView x:Name="rgvData" CanUserFreezeColumns="False" GridLinesVisibility="Horizontal" ItemsSource="" IsReadOnly="True" AutoGenerateColumns="False">
            <telerik:RadGridView.ChildTableDefinitions>
                <telerik:GridViewTableDefinition />
            </telerik:RadGridView.ChildTableDefinitions>
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding OrderDate}" Header="Order Date" />
                <telerik:GridViewDataColumn DataMemberBinding="{Binding EmployeeID}" Header="Employee" />
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Freight}" />
                <telerik:GridViewDataColumn DataMemberBinding="{Binding ShipCountry}" Header="Ship Country" />
                <telerik:GridViewDataColumn DataMemberBinding="{Binding ShipCity}" Header="Ship City" />
            </telerik:RadGridView.Columns>
            <telerik:RadGridView.HierarchyChildTemplate>
                <DataTemplate>
                    <telerik:RadGridView x:Name="RadGridView1" CanUserFreezeColumns="False" AutoGenerateColumns="False" ShowGroupPanel="False" IsReadOnly="True">
                        <telerik:RadGridView.Columns>
                            <telerik:GridViewDataColumn DataMemberBinding="{Binding CustomerID}" Header="Customer ID" />
                            <telerik:GridViewDataColumn DataMemberBinding="{Binding Address}" Header="Address" />
                            <telerik:GridViewDataColumn DataMemberBinding="{Binding City}" Header="City" />
                            <telerik:GridViewDataColumn DataMemberBinding="{Binding Country}" Header="Country" />
                        </telerik:RadGridView.Columns>
                    </telerik:RadGridView>
                </DataTemplate>
            </telerik:RadGridView.HierarchyChildTemplate>
        </telerik:RadGridView>
// The Child will host another template that will define it's own child.

What would be the best way to tackle this scenario. Should I just go by creating the grids through code behind? I would like to stick to xaml. Any pointers would help me decide !

Thanks,
Farhan

1 Answer, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 14 Mar 2011, 10:18 AM
Hi Farhan,

I am sending you a sample solution to your case. It supports two and three level hierarchy, which is determined at runtime. Please, refer to it and inform us if this approach fits into your requirements.

Regards,
Ivan Ivanov
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
GridView
Asked by
Farhan
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Share this question
or