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

TreeListView and self referencing data source

1 Answer 107 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
adrian
Top achievements
Rank 1
adrian asked on 12 Sep 2011, 09:01 AM
I want to display a self referencing table into a TreeListView.
Here is the xaml code:
<telerik:RadTreeListView x:Name="radGridView" ItemsSource="{Binding}" AutoGenerateColumns="False">
    <telerik:RadTreeListView.ChildTableDefinitions>
        <telerik:GridViewTableDefinition>
            <telerik:GridViewTableDefinition.Relation>
                <telerik:TableRelation IsSelfReference="True">
                    <telerik:TableRelation.FieldNames>
                        <telerik:FieldDescriptorNamePair
                            ParentFieldDescriptorName="ParentId"
                            ChildFieldDescriptorName="Id" />
                    </telerik:TableRelation.FieldNames>
                </telerik:TableRelation>
            </telerik:GridViewTableDefinition.Relation>
        </telerik:GridViewTableDefinition>
    </telerik:RadTreeListView.ChildTableDefinitions>
    <telerik:RadTreeListView.Columns>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" Header="Name" />
    </telerik:RadTreeListView.Columns>
</telerik:RadTreeListView>

All items are displayed without any indent so the tree looks like a list.

I'm confused because if I made some small changes and replace the TreeListView with a GridView the items are displayed properly and the items hierarchy is visible
<telerik:RadGridView x:Name="radGridView"  ItemsSource="{Binding}"  AutoGenerateColumns="False">
     <telerik:RadGridView.ChildTableDefinitions>
           <telerik:GridViewTableDefinition>
                 <telerik:GridViewTableDefinition.Relation>
                      <telerik:TableRelation IsSelfReference="True">
                        <telerik:TableRelation.FieldNames>
                              <telerik:FieldDescriptorNamePair
                                     ParentFieldDescriptorName="ParentId"
                                   ChildFieldDescriptorName="Id" />
                     </telerik:TableRelation.FieldNames>
                      </telerik:TableRelation>
                </telerik:GridViewTableDefinition.Relation>
               </telerik:GridViewTableDefinition>
            </telerik:RadGridView.ChildTableDefinitions>
         <telerik:RadGridView.Columns>
              <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" Header="Name" />
          </telerik:RadGridView.Columns>
</telerik:RadGridView>

I don't understand why the list and grid controls has different behaviour in the same situation.

1 Answer, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 12 Sep 2011, 01:26 PM
Hi,

 You need to use TreeListViewTableDefinition similar to our demos

Best wishes,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
TreeListView
Asked by
adrian
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Share this question
or