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

Binding to list of objects containing 2 lists

2 Answers 79 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 2
Richard asked on 12 Jan 2012, 09:21 PM
Hello all,

Scenario:
I am using the latest Radcontrols for Winforms (2011.3.11.1116) and I have a list of classes(categories) comprised of the following:
Name (string)
SubCats (List of objects(1) - each with props (Name, list of Reports))
Reports (List of objects(1) - each with props (list of Reports)) 

Reports is made up of Name and ID

Is it possible to use something like:
.Displaymember = "Name\Name\Name\Name"
.ChildMemeber = "categories\Reports\SubCats\Reports

or am I forced to loop through my class and populate the nodes manually?

Any help is appreciated.

2 Answers, 1 is accepted

Sort by
0
Richard
Top achievements
Rank 2
answered on 13 Jan 2012, 04:26 AM
Update: 

I finally just looped through the lists and programmatically built the node list for the tree. 

I'm still looking forward to hearing if there is another approach to binding to this type of data source.

Thanks in advance.

0
Julian Benkov
Telerik team
answered on 17 Jan 2012, 11:47 AM
Hello Richard,

You can not present the desired structure using object-relational binding mode. The issue is that the Reports object from the second level does not contain SubCats in its properties. You can present the structure with SubCats at the second level following your description of objects:

.DisplayMember = "Name\Name\Name"
.ChildMember = "categories\SubCats\Reports"

The solution in your case is to loop through the lists and programmatically build the nodes.

I hoe this helps. Let me know if you need further assistance.

Kind regards,
Julian Benkov
the Telerik team

SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

Tags
Treeview
Asked by
Richard
Top achievements
Rank 2
Answers by
Richard
Top achievements
Rank 2
Julian Benkov
Telerik team
Share this question
or