Drag & drop multiple node
See original GitHub issueHello,
I would like to drag and drop multiple leaf. I’ve activated the multi active tree options, and override the drop function (in the options.actionMapping) as follow :
drop: (tree, node, $event, { from, to }) => {
const activeNodes = tree.getActiveNodes();
if (activeNodes.length > 1) {
activeNodes.forEach(item => {
tree.moveNode(item, to);
});
} else {
tree.moveNode(from, to);
}
}
But it raises an arror if we try to move two nodes from the same parent. I found a workaround : in the tree.model.js, in the move function, I’ve replaced
var fromIndex = node.getIndexInParent();
var fromParent = node.parent;
if (!this._canMoveNode(node, fromIndex, to))
return;
var fromChildren = fromParent.getField('children');
by
var fromParent = node.parent;
var fromChildren = fromParent.getField('children');
var fromIndex = fromChildren.findIndex(item => item.id == node.id);
if (!this._canMoveNode(node, fromIndex, to))
return;
Maybe not the best solution, as it will recalculate the node position in his parent each time.
By the way, it would be great to add an “allowMultipleActive” option. It would be useful to avoid to select different kinds of node (for example, I active a leaf, I would like to prevent to activate a node with children)
Thanks for your work !
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:7 (2 by maintainers)
Top Results From Across the Web
TreeList - How to drag and drop multiple nodes
In recent versions, TreeList supports the capability to drag and drop multiple nodes out of the box. For this, set the ...
Read more >Drag drop of multiple nodes only shows one node in args
Hi,. When i drag multiple nodes in the treeview only one node is processed. So it looks like all the nodes are dragged...
Read more >Allow Drag and Drop of Multiple Nodes in Tree View. - MSDN
I have supported single node drag and drop,but how can the multiple nodes be selected and dropped to another node. 2.) While dragging/dropping ......
Read more >Drag & drop multiple node · Issue #548 - GitHub
To reproduce select at least two nodes via pressed Ctrl key and try to Drag and Drop them. https://stackblitz.com/edit/angular-6ys7sc ...
Read more >Dragging and Dropping Tree Nodes - L3HarrisGeospatial.com
Drag and drop-related properties of a tree widget node (the values of the DRAG_NOTIFY, DRAGGABLE, and DROP_EVENTS keywords) are inheritable. This means that ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Does it exist any way to drag and drop several nodes together? I have tried to select two nodes (via pressed Ctrl key) and move them but as a result I have got js error and only one node has been moved. I have used the same approach like @elzebu But changes in code didn’t help because on second call of function
node.parent
equals to null.To reproduce select at least two nodes via pressed Ctrl key and try to Drag and Drop them. https://stackblitz.com/edit/angular-6ys7sc
@ulymor @ebouvi01 You can implement this feature without error by some change code of @marekalgoud :
Pls pay attention you do not have to change tree.model.js.