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

Node path

2 Answers 601 Views
TreeView
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.
Ramesh
Top achievements
Rank 1
commented on 22 Nov 2022, 04:25 AM

How to achieve this parent and children's selection in kendo react framework ?
Konstantin Dikov
Telerik team
commented on 24 Nov 2022, 09:32 PM

Hi Ramesh,

With the KendoReact TreeView you can use the index of the checked item and split it by "_" to get the indexes of each of the parent items and add them to the array that holds the selected items indexes.

Hope this helps.

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
Tags
TreeView
Asked by
Alexey
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Richard
Top achievements
Rank 1
Share this question
or