javascript - Get selected node's parent in FancyTree - Stack Overflow

I'm working on FancyTree.js for my current project. I need a simple requirement in the Tree.My re

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
Add a ment  | 

2 Answers 2

Reset to default 4

I 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

相关推荐

  • javascript - Get selected node's parent in FancyTree - Stack Overflow

    I'm working on FancyTree.js for my current project. I need a simple requirement in the Tree.My re

    1天前
    50

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信