SelectedValuePath

2 posts, 0 answers
  1. Marcus Lambert
    Marcus Lambert avatar
    41 posts
    Member since:
    Aug 2009

    Posted 02 Dec 2009 Link to this post

    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
  2. Miroslav
    Admin
    Miroslav avatar
    922 posts

    Posted 03 Dec 2009 Link to this post

    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.
  3. DevCraft banner
Back to Top