TreeListView and self referencing data source

2 posts, 0 answers
  1. adrian
    adrian avatar
    1 posts
    Member since:
    Sep 2011

    Posted 12 Sep 2011 Link to this post

    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.

  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 12 Sep 2011 Link to this post

    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
  3. DevCraft banner
Back to Top