angular-tree-component
angular-tree-component copied to clipboard
Drag external element into tree
Hi Team,
Please provide an example as to how to drag an external element into the tree.
The documentation only states to provide a custom handler, but do i need to create a new TreeNode from the external element? If this has been answered at some point, with an example or some further guidance, please do let me know,
same issue
how to determine if the nodes is coming in external tree?
@musti2 Hi where you able to find out how to do it? BR
I suggest to create a function createNode that can be used in the mapping drop callback to ease the job of node creation. By looking at the implementation of moveNode I was able to create the node like this
actionMapping: {
mouse: {
drop: (tree, node, $event, {from, to}) => {
// tree.createNode(from, to); in the futur?
if (!to.parent.getField('children')) {
to.parent.setField('children', []);
}
const toChildren = to.parent.getField('children');
// here my from is {
// id: 8,
// name: 'Parent 8'
// }
// so it does have an id but you can use your getNodeClone to generate a
// new node with a unique ID
toChildren.splice(to.index, 0, from);
tree.update()
}
}
}