Extended grouping

2 posts, 0 answers
  1. David
    David avatar
    8 posts
    Member since:
    Mar 2011

    Posted 18 Mar 2013 Link to this post


    I need some support to create a treeview, that is bound to a dataset and hierarchically displays the content in the following way:

    Customer 1

         Orders (<- Group node)

             Order 1

         Shipping Notes (<- Group node)

             Shipping Note 1

             Shipping Note 2

         Invoices (<- Group node)

             Invoice 1

         Order 2

         Order 3

    In the underlying relational structure are the four datatables "customer", "orders", "shipping notes" and "invoices" with parent-child relationships between "customer" - "orders", "orders" - "shipping notes" and "orders" - "invoices". The dataset structure corresponds to the database structure, so I'm not able to change it.

    I tried to extend the basic grouping example from Valentin Stoychev using a CollectionViewSource, but i was not able to combine them.

    Can you give me a hint how get it to work?

  2. Petar Mladenov
    Petar Mladenov avatar
    3082 posts

    Posted 21 Mar 2013 Link to this post

    Hello David,

     As I managed to understand, the Orders Entity can have different kinds of children -orders, shipping notes, invoices. Or you have to combine both grouping of items in a parent item and having children from different types. In both cases I highly recommend you to use ViewModel wrapper classes to your DB data. Build a ViewModel hierarchy to reflect the way you need to display a hierarchical data in the RadTreeView. With a proper ViewModels  the grouping comes out of the box - you can create a suitable ViewModel to display group of child items. As for the problem with different kinds of children - just make sure that the child ViewModels implement a common Interface or extend a common  class. Attached is a sample solution demonstrating an approach with different kinds of children - file/folder hierarchy (a folder can have both child folders and child files). Hope you will find it useful.

    Kind regards,
    Petar Mladenov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top