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,326 times
2
-
[How to accept an answer that solved your problem?](http://meta.stackexchange.com/a/5235) – Jun 02 '14 at 04:38
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.
![](../../users/profiles/1141370.webp)
Gruff Bunny
- 26,318
- 10
- 66
- 56
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.
![](../../users/profiles/1468586.webp)
Minesh
- 2,226
- 1
- 11
- 21
0
var parent = node.getParent();
var parentnode = parent.data.key;
In parentnode you will get the value of parent node.
![](../../users/profiles/559745.webp)
Floern
- 31,495
- 23
- 98
- 115