How to change the hierarchy (grouping) in TreeView

2 posts, 0 answers
  1. Jon
    Jon avatar
    1 posts
    Member since:
    Mar 2008

    Posted 01 Jul 2009 Link to this post

     I want to be able to change the hierarchy in a treeview based on user request.  For example,  I have a List<vehicles> like this (below) that I want to show in a TreeView.

    Ford       Red        2-door  2002
    Ford       Blue       2-door  2003
    Jeep      Silver     4-Door  2005
    Toyota  Gray      4-door  2008
    Jeep      White    Hatch    2004
    Toyota  White    2-door  2001

    No big deal until I want to change the grouping, that is, allow make or color or #-doors or year to be the first level in the hierarchy.  I don’t see any way to parameterize the binding source in the HierarchicalDataTemplate or use code-behind.  What I’d like to end up with is a treeview like this:

                    + Ford
                                    Red
                                    Blue
                    + Jeep
                                    Silver
                                    White
                    +Toyota
                                    Gray
                                    White

    Or, by a user selection, regroup the treeview to this:

                    +Red
                                    Ford
                    +Blue
                                    Ford
                    + Silver
                                    Jeep
                    +Gray
                                    Toyota
                    +White
                                    Jeep
                                    Toyota

    All the data is in a Collection (objects of class vehicle in my example) and ideally, I’d like to be able to group and sort that list using LINQ (perhaps).  Any change of implementing this with TreeView?

  2. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 03 Jul 2009 Link to this post

    Hi Jon,

    we are working towards enabling this scenario for the Treeview, but for the moment only Rad GridView supports grouping out of the box.

    All the best,
    Valentin.Stoychev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top