7

I have difficulties in selecting a given node from fancytree plugin.

So, I have tried something like:

$("#tree").fancytree("getTree").visit(function(node){
    node.select(n);
});

where "n" is any number representing the node id, but it doesn'work, even if the select() function exists in documentation

Could someone help?

rosuandreimihai
  • 656
  • 3
  • 16
  • 39

1 Answers1

16
var tree = $("#tree").fancytree("getTree");
var node = tree.getNodeByKey(n);
node.setSelected(true);
Rasheed Jahjah
  • 556
  • 7
  • 13
  • 3
    Maybe you also need this `node.setActive(true);`. – Mike de Klerk Oct 10 '17 at 13:03
  • 2
    It would seem that as of version 2.25 of fancytree, you have to BOTH do a node.setSelected(true) and a node.setActive(true) to make the tree show a selected node as actually selected. – Thomas N Nov 03 '17 at 06:58