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

Build a hierachy from a flat list ?

4 Answers 225 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 25 Sep 2015, 03:09 AM

Is it possible to create a hierarchical tree list view from a flat list, much in the way you can with a TreeList ( http://docs.telerik.com/devtools/wpf/controls/radtreeview/how-to/bind-to-self-referencing-data.html ) ?

We have a data structure where the objects have the ids of their parents, and we would much rather bind to a flat list, than rebuild the hierarchy.

I had a look at the hierarchical grid view (http://docs.telerik.com/devtools/wpf/controls/radgridview/hierarchical-gridview/self-referencing-grid.html ), but that still seems to put children at the top level (as well as the child level).

 

4 Answers, 1 is accepted

Sort by
0
Michael
Top achievements
Rank 1
answered on 25 Sep 2015, 04:01 AM

I've tried the following xaml :

<telerik:RadTreeListView.ChildTableDefinitions>
                <telerik:TreeListViewTableDefinition>
                    <telerik:TreeListViewTableDefinition.Relation>
                        <telerik:TableRelation IsSelfReference="True">
                            <telerik:TableRelation.FieldNames>
                                <telerik:FieldDescriptorNamePair
                                    ParentFieldDescriptorName="Id"
                                    ChildFieldDescriptorName="ParentId" />
                           </telerik:TableRelation.FieldNames>
                        </telerik:TableRelation>
                    </telerik:TreeListViewTableDefinition.Relation>
                </telerik:TreeListViewTableDefinition>
            </telerik:RadTreeListView.ChildTableDefinitions>

But all I get is a flat list.

The model looks like this :

public class Item
{
    public string Id {get; set;}
    public string ParentId {get; set;}
}

Where ParentId is null if the item is a top level item.
0
Stefan
Telerik team
answered on 29 Sep 2015, 03:07 PM
Hi Michael,

Can you please take a look at the Self reference with tree list view forum thread, as this topic is already discussed in it?

Hope it helps.

Best Regards,
Stefan X1
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Michael
Top achievements
Rank 1
answered on 29 Sep 2015, 11:19 PM

No - that doesn't help. It suggests using a grid view instead of a tree list view.

I found a post elsewhere (http://www.telerik.com/forums/treelistview-and-self-referencing-data-source) where this was raised, and a solution presented, which is what I've shown in the above xaml.

0
Stefan
Telerik team
answered on 02 Oct 2015, 04:06 PM
Hello Michael,

Upon further investigation, it seems that using RadTreeListView for a self-referenced data source is not supported. Please excuse me for misguiding you.

For such scenario, I can suggest you using RadGridView with a RadTreeListView structure, as demonstrated in this forum thread.

I hope it works for you.

Best Regards,
Stefan X1
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
TreeListView
Asked by
Michael
Top achievements
Rank 1
Answers by
Michael
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or