Binding to Object-relational Data
RadTreeView has the ability to bind to related data of custom objects which have member collections of related objects (ORM generated classes for example).
Consider the following class diagram:
There are three classes named Customer, Order and Order_Detail. The data relations in the case of custom objects are represented by properties which provide references to collections of related objects. In this case the Customer class has a property named Orders which is a collection of Order objects. This is the first relation. The second relation is the Order_Details property in the Order class, it offers a reference to a collection of Order_Details. Once you have such class composition, it is trivial for RadTreeView to represent it visually in your application.
The two steps that must be done are these:
1. Set the DataSource of RadTreeView to a collection of your root objects (a collection of Customer object in this case):
IEnumerable<Customer> customers = context.GetTable<Customer>().ToList(); this.radTreeView1.DataSource = customers;
Dim customers As IEnumerable(Of Customer) = context.GetTable(Of Customer)().ToList() Me.RadTreeView1.DataSource = customers
The above context object is created by binding the project to the NorthWind database using LINQ to SQl
2. Set the DisplayMember corresponding to the DisplayMembers of the different types of objects and set the ChildMember corresponding to the names of the properties that represent the collections of sub objects.
this.radTreeView1.DisplayMember = "ContactName\\ShipName\\UnitPrice"; this.radTreeView1.ChildMember = "Customers\\Orders\\Order_Details";
Me.RadTreeView1.DisplayMember = "ContactName\ShipName\UnitPrice" Me.RadTreeView1.ChildMember = "Customers\Orders\Order_Details"
As a result, we get the following hierarchy in RadTreeView: