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

SelectedValuePath

1 Answer 103 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Marcus Lambert
Top achievements
Rank 1
Marcus Lambert asked on 02 Dec 2009, 10:16 PM
Hi,
I have a databound nodes to a Hierarchical ObservableCollection.
I am seeing some wierd stuff in the SelectedValuePath in that it being null even though a item is selected ?
Also I am seeing that the selected container full path contains
KnowledgeMill.KMCS.Client.Entities.HierarchicalTNode\KnowledgeMill.KMCS.Client.Entities.HierarchicalTNode\KnowledgeMill.KMCS.Client.Entities.HierarchicalTNode

Is this ment to happen or have i done something mad !

Marcus

1 Answer, 1 is accepted

Sort by
0
Miroslav
Telerik team
answered on 03 Dec 2009, 11:04 AM
Hello Marcus Lambert,

Straight to your questions:
The SelectedValuePath specifies the path (normally the name of the property) that will be used to resolve the SelectedValue depending on the SelectedItem.

Example: You have an Entity Person which has a property FirstName.

If you set the SelectedValuePath to "FirstName" then the SelectedValue property will equal the value of the FirstName for the selected entity, e.g. "John"

I understand that the name of the property may be mistaken for "The Path of the SelectedItem". The easiest way to retrieve this is to call

treeView.SelectedCotnainer.FullPath

For your second question:
The path for an item is built by calling .ToString(). By default the method returns the class name so this is why you see this strange path.

You can override the ToString method for your items or set the TextSearch.TextPath property on the TreeView that will specify the property that will be sued to build that path, i.e.:

telerik:TextSearch.TextPath = "Id"

If you have and Id property on your items, it will be used to create the path.

Then you can use  this same path for methods like GetItemByPath or ExpandItemByPath.

Greetings,
Miroslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
TreeView
Asked by
Marcus Lambert
Top achievements
Rank 1
Answers by
Miroslav
Telerik team
Share this question
or