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

TreeNode contructors

4 Answers 64 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Maxime
Top achievements
Rank 2
Maxime asked on 27 Feb 2010, 03:13 PM
Hi,

I was just wondering if there was any reason there are no overrides when instantiating a RadTreeNode to set BOTH the TEXT value AND Name Value of the node?

So lets say I wanna create a array of RadTreeNode from some data I have, since there just a constructor having the text (and others but still no NAME property) I have to loop through them to set one by one their name value...


Thanks :)

4 Answers, 1 is accepted

Sort by
0
Victor
Telerik team
answered on 01 Mar 2010, 08:48 AM
Hello Maxime,

Thank you for writing. I suggest you do not use the Name property at all since we are considering deprecating it. If you need to keep some custom information in the node I suggest using the Tag property. If the Tag property is not appropriate for some reason I suggest inheriting from RadTreeNode and declaring your own property. Please write again if you have other questions.

Regards,
Victor
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Maxime
Top achievements
Rank 2
answered on 01 Mar 2010, 12:59 PM
Hi,

Thanks for your answer.

So if I bind data to the treeview, there's no way for me to have an ID and a TEXT value juste like a dropdown per say?
0
Victor
Telerik team
answered on 02 Mar 2010, 08:45 AM
Hello Maxime,

Thank you for writing. When you are using data binding there is little control over the creation of nodes. However, you have a Text (indicated by DisplayMember) property and a value which corresponds to the ValueMember property will be stored in the Tag of each RadTreeNode. Here is a small comparison of how RadListBox and how RadTreeView binds to data:

RadListBox:

radListBox.DisplayMember = "Name";
radListBox.ValueMember = "Id";
radListBox.DataSource = dataSource;
 
// Values are retrieved like so:
object value = (radListBox.SelectedItem as RadListBoxItem).DataBoundItem;

RadTreeView:

radTreeView.DisplayMember = "Name";
radTreeView.ValueMember = "Id";
radTreeView.DataSource = dataSource;
 
object value = radTreeView.SelectedNode.Tag;

Write again if you have other questions.

Best wishes,
Victor
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Stefan
Telerik team
answered on 22 Mar 2011, 04:45 PM
Hi Maxime,

Please note that in Q1 2011 we have introduced a major upgrade of RadTreeView control, which is now virtualized and fully customizable. Feel free to download the latest release and try it out. For more information on our latest release refer to this blog post

Greetings,
Stefan
the Telerik team
Tags
Treeview
Asked by
Maxime
Top achievements
Rank 2
Answers by
Victor
Telerik team
Maxime
Top achievements
Rank 2
Stefan
Telerik team
Share this question
or