Edit this page

Basic Hierarchies

The RadGridView allows you to display hierarchical data in the form of nested grid views. To do so you have to define a table definition for each subset of data you want to display. Such a definition can be done by creating a GridViewTableDefinition object and adding it to the ChildTableDefinitions collection of the RadGridView.

The GridViewTableDefinition class is to be found in the same assembly and namespace as the RadGridView control. To learn how to create a GridViewTableDefinition take a look at the following lines of code.

<telerik:GridViewTableDefinition />

GridViewTableDefinition d = new GridViewTableDefinition();
Dim d As New GridViewTableDefinition()

After that set its Relation property to the name of the property containing the subset of data. In this way you define the data source for the nested tables. You set the property to an object of type PropertyRelation.

The ParentPropertyName of the PropertyRelation object represents the name of the property that will be used as a source for the nested table.

<telerik:GridViewTableDefinition>
    <telerik:GridViewTableDefinition.Relation>
        <telerik:PropertyRelation ParentPropertyName="Orders" />
    </telerik:GridViewTableDefinition.Relation>
</telerik:GridViewTableDefinition>

GridViewTableDefinition td = new GridViewTableDefinition();
td.Relation = new PropertyRelation("Orders");
Dim td As New GridViewTableDefinition()
td.Relation = New Telerik.Windows.Data.PropertyRelation("Orders")

Now you can add the definition to the ChildTableDefinitions collection.

<telerik:RadGridView x:Name="radGridView"
                 AutoGenerateColumns="False">
    <telerik:RadGridView.ChildTableDefinitions>
        <telerik:GridViewTableDefinition>
            <telerik:GridViewTableDefinition.Relation>
                <telerik:PropertyRelation ParentPropertyName="Orders" />
            </telerik:GridViewTableDefinition.Relation>
        </telerik:GridViewTableDefinition>
    </telerik:RadGridView.ChildTableDefinitions>
</telerik:RadGridView>

this.radGridView.ChildTableDefinitions.Add(td);
Me.radGridView.ChildTableDefinitions.Add(d)

The GridViewTableDefinition object also exposes a ChildTableDefinitions property, which means that you can nest grids on more than one level.

See Also