Build a hierachy from a flat list ?

5 posts, 0 answers
  1. Michael
    Michael avatar
    19 posts
    Member since:
    Aug 2014

    Posted 24 Sep 2015 Link to this post

    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).

     

  2. Michael
    Michael avatar
    19 posts
    Member since:
    Aug 2014

    Posted 24 Sep 2015 Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Stefan X1
    Admin
    Stefan X1 avatar
    514 posts

    Posted 29 Sep 2015 Link to this post

    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
  5. Michael
    Michael avatar
    19 posts
    Member since:
    Aug 2014

    Posted 29 Sep 2015 in reply to Stefan X1 Link to this post

    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.

  6. Stefan X1
    Admin
    Stefan X1 avatar
    514 posts

    Posted 02 Oct 2015 Link to this post

    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
Back to Top
UI for WPF is Visual Studio 2017 Ready