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

Databind collections of disparate types

1 Answer 59 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
MartinM
Top achievements
Rank 1
MartinM asked on 11 Sep 2014, 06:48 PM
Hi,
I am able to successfully bind hierarchical data with two levels (for example, "Categories\Products"), but I would like to databind 3 different collections of different types, the result being something like:

+Categories
    CategoryA
    CategoryB
+Products
    Product1
    Product2
+Location
    LocationX
    LocationY

where

public IList<Category> Categories { get; set; }
public IList<Product> Products  { get; set; }
public IList<Location> Locations  { get; set; }


Similar to this question: http://www.telerik.com/forums/treeview-binding-to-multiple-object-types-in-mvvm

Aside from 'selecting' each item into a new common type, is there a better way to do this?

Thanks for your input,



1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 16 Sep 2014, 03:24 PM
Hi Martin,

Thank you for writing.

In this case you cannot directly bind the treeview to the datasource object. However you can use the load on demand feature and manually populate the nodes. The attached project contains sample implementation of this approach. 

I hope this will be useful.

Regards,
Dimitar
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
Treeview
Asked by
MartinM
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or