Is there any way to find dynatree's root node details? Supposed tree has 5 level and i selected fifth level's node . I want to get selected nodes and its parents details till root. Thanks in advance.
Asked
Active
Viewed 4,449 times
3 Answers
3
The visitParents function on the node should do what you want:
node.visitParents(function (node) {
// do stuff with node
}, true);
Passing true as the second parameter includes the node as well as it's parents.

Gruff Bunny
- 27,738
- 10
- 72
- 59
2
Try below method:
node.getKeyPath()
It should return string of keys from leaf to root node like below
/_3/_23/_26/_27
You should be then able to retrieve the any node details of that branch by parsing above string
var node = $("#tree").dynatree("getTree").getNodeByKey("3")
This might not be the exact solution but should give you the direction to get to your solution.

Minesh
- 2,284
- 1
- 14
- 22
0
var parent = node.getParent();
var parentnode = parent.data.key;
In parentnode you will get the value of parent node.

Floern
- 33,559
- 24
- 104
- 119