mbraak / jqTree

Tree widget for jQuery
https://mbraak.github.io/jqTree/
Apache License 2.0
1.02k stars 177 forks source link

Dynamically open nodes #12

Closed mtauban closed 12 years ago

mtauban commented 12 years ago

I'm using jqTree with Symfony2 (and some bad looking ajax requests) to construct a tree and store it as a nestedTree doctrine object.

When creating an object, if all goes well, I load the subnode with your new dev/loadData function, and if the parent node is open, the freshly-created-subnode appears magically under its parent.

I'm looking for a "nice" way to dynamically open a node (in my case, the parent node, to help the user understanding where he's adding nodes to the tree). Is there somehow a way to open a node object (node.open() ?) and its parents within hierarchy ?

mbraak commented 12 years ago

The function 'selectNode' does that. This function is not documented yet.

function selectNode(node, must_open_parents);

If you have the 'node', you can do this:

The option 'selectable' must be true for this.

mtauban commented 12 years ago

Works like a charm. Thanks for your help and for your hardwork on this lightweight extension.

lbineau commented 11 years ago

It doesn't seem to work with IE (7 & 8 & 9). If the node haven't got parents it work well (it is selected). But in the case the node has parents, they are not opened even if 'selectable' and 'must_open_parents' are set to true... It is ok for Chrome and Firefox for their lastest updates.

Any ideas

mbraak commented 11 years ago

I will look into it

mbraak commented 11 years ago

I cannot reproduce the error. I tried this with examples/example2:

<p>
    <a href="#" id="select-node">select node</a>
</p>
$tree.tree({
    selectable: true
});

$('#select-node').click(
    function() {
        var node = $tree.tree('getNodeByName', 'Ornithomimosaurians');
        $tree.tree('selectNode', node, true);
    }
);

By the way, you could also try the dev branch. The selectNode in this branch has changed.

lbineau commented 11 years ago

This morning it is working. Some cache noob problem I think... Thank for your concern and sorry for the inconvenient.