I'm working on FancyTree.js for my current project. I need a simple requirement in the Tree.
My requirement is I need to get current selected node's parent node. I'm searching everything, but I can't find the solution.
This link about FancyTreeApi has many options. But none of those are related to my requirement.
EDITED
I have done to get the current selected node using the below code.
var node = $("#tree").fancytree("getActiveNode");
if( node ){
alert("Currently active: " + node.title);
}else{
alert("No active node.");
}
I'm working on FancyTree.js for my current project. I need a simple requirement in the Tree.
My requirement is I need to get current selected node's parent node. I'm searching everything, but I can't find the solution.
This link about FancyTreeApi has many options. But none of those are related to my requirement.
EDITED
I have done to get the current selected node using the below code.
var node = $("#tree").fancytree("getActiveNode");
if( node ){
alert("Currently active: " + node.title);
}else{
alert("No active node.");
}
Share
Improve this question
edited Feb 23, 2017 at 8:46
halfer
20.4k19 gold badges109 silver badges202 bronze badges
asked Feb 23, 2017 at 7:34
Mari SelvanMari Selvan
3,7924 gold badges24 silver badges42 bronze badges
1
- Show us what did you try? – MysterX Commented Feb 23, 2017 at 7:36
2 Answers
Reset to default 4I have researched your question and you can do it in some ways:
First:
var node = $("#tree").fancytree("getActiveNode");
if( node ){
console.log("Parent of FancytreeNode type: ");
console.dir(node.parent);
}else{
console.log("No active node.");
}
where node.parent
is parent tree node
Second:
var node = $("#tree").fancytree("getActiveNode");
if( node ){
console.log("Parent of HTMLElement type: ");
console.dir(node.li.parentNode);
}else{
console.log("No active node.");
}
where node.li
is HTML element of active tree node and node.li.parentNode
is it's parent HTML element
Use Below code
This Should be also helpful For You
var node = $("#tree").fancytree("getActiveNode");
if( node ){
alert(node.parent);//Give Detail about the parent
alert(node.parent.title);//Give parent node Name
}else{
alert("Select a node First");
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744921668a4601170.html
评论列表(0条)