Version

Defining a Self Related Hierarchical Structure

Please note that this control has been retired and is now obsolete to the XamDataGrid control, and as such, we recommend migrating to that control. It will not be receiving any new features, bug fixes, or support going forward. For help or questions on migrating your codebase to the XamDataGrid, please contact support.

The xamGrid control also allows you to use column layouts to define self-related hierarchical data structures. A typical example of self-related data is an employee hierarchy, where managers have employees, who themselves are also managers and have employees.

The following example shows you how display a self-related structure by binding xamGrid to the Employees collection referred to at the beginning of the article. All you need to do is create a ColumnLayout object that uses the TargetTypeName to match the Employees collection exposed by the Employee data source.

In XAML:

<ig:XamGrid x:Name="xamGrid1" AutoGenerateColumns="False">
    <ig:XamGrid.ColumnLayouts>
        <ig:ColumnLayout Key="DirectReports" TargetTypeName="Employee">
            <ig:ColumnLayout.Columns>
                <ig:TextColumn Key="Id" />
                <ig:TextColumn Key="Name" />
                <ig:TextColumn Key="JobTitle" />
            </ig:ColumnLayout.Columns>
        </ig:ColumnLayout>
    </ig:XamGrid.ColumnLayouts>
</ig:XamGrid>
sl xamGrid Define Column Layout 08.png

You can also control how many levels deep the xamGrid will traverse the self-related data structure by setting the control’s MaxDepth property.

In XAML:

<ig:XamGrid x:Name="xamGrid1" AutoGenerateColumns="False" MaxDepth="1">
Note
Note:

The MaxDepth property is a zero-based value, where zero is the root column layout. So in this case, the max depth is one level past the root layout: MaxDepth = 1.