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

binding

1 Answer 44 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Chom
Top achievements
Rank 1
Chom asked on 30 Sep 2013, 10:01 PM
Hello,

I am having trouble trying to figure out the binding and I am not sure if it is possible.

I have a base node with several child nodes and within those child nodes I need to add additional child nodes.

I have managed to bind the first level child nodes, but I cannot figure out how to add the additional child nodes.

Below is a sample.

Thank you,

Chom
IList<Project> project = new List<Project>();
IList<Topic> topic = new List<Topic>();
IList<Cloud> cloud = new List<Cloud>();
IList<Trend> trend = new List<Trend>();
IList<Schedule> schedule = new List<Schedule>();
 
cloud.Add(new Cloud { Name = "cloud1" });
cloud.Add(new Cloud { Name = "cloud2" });
 
trend.Add(new Trend { Name = "trend 1" });
trend.Add(new Trend { Name = "trend 2" });
 
schedule.Add(new Schedule { Name = "sched 1" });
schedule.Add(new Schedule { Name = "sched 2" });
 
topic.Add(new Topic { Name = "Clouds", CloudAssociation = cloud });
topic.Add(new Topic { Name = "Trends", TrendAssociation = trend });
topic.Add(new Topic { Name = "Schedules", ScheduleAssociation = schedule });
 
//Project.
project.Add(new Project { Name = "My Project", TopicAssociation = topic });
 
 
radTreeView1.DisplayMember = "Name\\Name\\Name";
radTreeView1.ParentMember = "Project\\TopicAssociation";
radTreeView1.ChildMember = "Project\\TopicAssociation\\CloudAssociation";
radTreeView1.DataSource = project;

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 03 Oct 2013, 02:59 PM
Hi Chom,

Thank you for writing.

I have tested the code provided and it seems to be working fine on my end - please refer to the attached image.

Basically, you have one Project, with the respective TopicAssociation containing CloudAssociation, TrendAssociation and ScheduleAssociation. Since you have set the ParentMember to be "Project\\TopicAssociation", you get one parent node (MyProject) with tree child nodes - Clouds, Trends and Schedules. 

Then you set the ChildMember to "Project\\TopicAssociation\\CloudAssociation" and the tree loads the data for from the CloudAssociation as child nodes for the Cloud node. 

If I understand correctly, you would like that all three child nodes - Clous, Trend and Scheduler to have their child nodes. To achieve this, you should use the Load on demand feature of RadTreeView. For more information about it please refer to the following article: http://www.telerik.com/help/winforms/treeview-data-binding-load-on-demand.html.

I hope that you find this information useful.
 

Regards,
Stefan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
Treeview
Asked by
Chom
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or