Node path

3 posts, 0 answers
  1. Alexey
    Alexey avatar
    3 posts
    Member since:
    Oct 2010

    Posted 09 Mar 2012 Link to this post

    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:

        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?

  2. Alexander Valchev
    Alexander Valchev avatar
    2895 posts

    Posted 12 Mar 2012 Link to this post

    Hi Alexey,

    I suggest using the jQuery parentsUntil function. For example:
    var treeView = $("#treeview").data("kendoTreeView");
    var selected =;
    $(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.

    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!
  3. Richard
    Richard avatar
    149 posts
    Member since:
    Feb 2012

    Posted 08 Apr 2012 Link to this post shows how to use $.map to build the textual path to the selected node
Back to Top