Fancytree jQuery plugin - select node
Asked Answered
O

1

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?

Ordinal answered 2/12, 2014 at 20:5 Comment(2)
Could you provide a sample fiddle in order to reproduce your issue?Harrold
Sadly, I can't reproduce it.. I struggled to find something useful for selecting a node dynamically but there is no example at all..Ordinal
U
16
var tree = $("#tree").fancytree("getTree");
var node = tree.getNodeByKey(n);
node.setSelected(true);
Unstop answered 31/1, 2015 at 1:31 Comment(2)
Maybe you also need this node.setActive(true);.Ursa
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.Intellectual

© 2022 - 2024 — McMap. All rights reserved.