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

[Solved] TreeView JavaScript Parent Node of Selected Item

1 Answer 120 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Steve
Top achievements
Rank 1
Steve asked on 09 Jan 2012, 06:19 PM
Good afternoon,

    I have what I believe to be a simple question regarding client-side events with the MVC TreeView control. What I am trying to determine is the parent node of a selected node. For example. Suppose this TreeView:

 - RootNode
      - ChildNode1
      - ChildNode2

If ChildNode1 was selected, I want to be able to get RootNode in the JavaScript. I know that I can do...

var treeview = $('#trOfferings').data('tTreeView');
var nodeText = treeview.getItemText(e.item);

to determine ChildNode1, but there does not appear to be any function or method in order to determine the parent node. Is there some way of doing this client-side? Thank you for your time.


1 Answer, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 10 Jan 2012, 09:05 AM

You need to get the parent node with jQuery, using the e.item as a reference.

var parentNodeText = treeview.getItemText($(e.item).parent().closest(".t-item")); 

Kind regards,
Alex Gyoshev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
Tags
TreeView
Asked by
Steve
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Share this question
or