I am using primeng p-tree component and i would like to forbid some node type to be drop inside another node type.
for exemple i have node with type folder and another node with type file and i only want that node of type file move inside a node of type folder. I want to forbid moving folder node inside another folder node. (and other rules
<p-tree [value]="filesTree7" draggableNodes="true" droppableNodes="true" dragdropScope="files" selectionMode="single" [(selection)]="selectedFile2" [contextMenu]="cm" (contextmenu)="onContextMenu($event)"
(onNodeDrop)="onNodeDrop($event)"></p-tree>
I tried to stop propagation of the drop like this :
onNodeDrop(event) {
console.log("onNodeDrop");
event.originalEvent.stopPropagation();
event.originalEvent.preventDefault();
return;
}
but it is not working.
when i have a look to primeng code here : primeng tree component code source it seems that onNodeDrop event is emit too late.
Do you have any ideas how i can implement what i need ?
If you want that a single node isn't droppable or draggable you must set params draggable/droppable in array:
{
"label": "Note e Commenti",
"icon": "fa-file-word-o",
"draggable":false,
"droppable":false,
"data": {
"id": 1,
"nome": "Note e Commenti",
"testo": "Note e Commenti",
"idCategoria": 2,
"idTipologia": 1
}
},
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With