This is a migrated thread and some comments may be shown as answers.
Node path
2 Answers 224 Views
This is a migrated thread and some comments may be shown as answers.
Alexey
Top achievements
Rank 1
Alexey asked on 09 Mar 2012, 12:28 PM
Hi Guys,

Is there any way to get a selected node path from the TreeView?

What I am trying to do is to implement a 'select' event handler:

$('#myTreeView').kendoTreeView({
    select: function(data) {
        //DO Something
        //DO Something else
        var path = GetNodePath(); //Implementation needed
         
        publishEvent("MyItemActivated", path); //pseudocode
    }
});

Ideally I would like to get an array of all the parents all the way up to the root of the tree.

How would I do it?

Cheers,
Alexey.

2 Answers, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 12 Mar 2012, 02:59 PM
Hi Alexey,

I suggest using the jQuery parentsUntil function. For example:
var treeView = $("#treeview").data("kendoTreeView");
var selected = treeView.select();
 
$(selected).parentsUntil($("#treeview"), "li");

In this way you would be able to retrieve an array of all <li> nodes that are parents of the currently selected item.

Greetings,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Richard
Top achievements
Rank 1
answered on 08 Apr 2012, 08:49 PM
http://jsfiddle.net/bZXnR/1/ shows how to use $.map to build the textual path to the selected node
Asked by
Alexey
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Richard
Top achievements
Rank 1
Share this question
or