mbraak / jqTree

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

[move_info].moved_node.parent / Problems #8

Closed benda95280 closed 12 years ago

benda95280 commented 12 years ago

Dear Mbraak,

I'm having probleme when i want to move a node (tree.move) : If i try to access (e.move_info.moved_node.parent) i have the parent of (e.move_info.target_node.parent)

How can i do if i want to access to the parent of Moved_node ? ( i want to see if the moved node is root or not )

And can you tell me how i can add a node dynamically ?

Thanks a lot.

mbraak commented 12 years ago

Hello,

The 'move_info' does not contain information about the original position of the moved node. I think it will be a good idea to add this info in a new version of jqTree.

There is a workaround, however. You can use the 'onCanMove' event to get information about the moved node:

var original_parent = null;

$('#tree1').tree({
    data: data,
    dragAndDrop: true,
    onCanMove: function(node) {
        original_parent = node.parent;
        return true;
    }
});
mbraak commented 12 years ago

At this moment it's not possible to add a node dynamically. Perhaps this is nice feature for the new version.

The 'dev' branch does contain a function 'loadData' which can replace all data in the tree.

$('#tree1').tree('loadData', new_data);
mbraak commented 12 years ago

The 'dev' branch contains a new feature for loading a subtree. The function 'loadData' now accepts a 'parent_node' parameter.

$tree.tree('loadData', data, parent_node);
mbraak commented 12 years ago

The 'tree.move' event now contains the 'previous_parent' property. This is implemented in the 'dev' branch.

mbraak commented 12 years ago

Implemented in version 0.7.