Search code examples
drag-and-dropjqtree

Drag and drop between two trees with jqTree


By default, as I know, jqTree doesn't support interaction between trees. How can I add drag-and-droppin' ability with a small effort?


Solution

  • I did it using the double click event

    var Tree1 = $('#treeId').tree({
        data: someData,
        dragAndDrop: true,
      }).bind(
          'tree.dblclick',
          function(event) {
              // event.node is the clicked node
              console.log(event.node);
              var selectedNode = Tree2.tree('getSelectedNode');
              console.log(selectedNode);
              Tree2.tree('addNodeAfter',event.node,selectedNode);
          }
      );
    

    node will be sent to the other tree on the double click event