Basic Hierarchies

Figure 1: Hierarhical RadGridView

Hierarhical RadGridView

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.

Defining the GridViewTableDefinition

Specific for the GridViewTableDefinition is that it needs to have 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.

Example 1: Defining the GridViewTableDefinition

        <telerik:PropertyRelation ParentPropertyName="Orders" />

Example 2: Defining the GridViewTableDefinition programmatically

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.

Example 3: Adding the GridViewTableDefinition to the ChildTableDefinitions

<telerik:RadGridView x:Name="radGridView"
                <telerik:PropertyRelation ParentPropertyName="Orders" />

Example 4: Adding the GridViewTableDefinition to the ChildTableDefinitions programmatically


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

Check if a hierarchy item is expanded

The IsExpanded method can also be used to check whether a group is expanded. More information can be found in the Programmatic Grouping topic.

In case when checking whether a given hierarchical item is expanded the IsExpanded method of RadGridView comes in handy. When an item is passed as a parameter to it, it will return a boolean value determining whether its hierarchy is expanded or not.

Example 5: Call the IsExpanded method of RadGridView

bool isExpanded = this.clubsGrid.IsExpanded(this.clubsGrid.Items[0]);
Dim isExpanded As Boolean = Me.clubsGrid.IsExpanded(Me.clubsGrid.Items(0))

See Also

In this article
Not finding the help you need? Improve this article