Surface tree: do not delete node after dragging
Is it possible to remove a node from the original PrimeFacesTree after dragging it? The default behavior is that a node that has been dragged and dropped elsewhere is removed. Can I prevent this?
I am using Primefaces 4.0
+3
Alex
source
to share
1 answer
There is no ready-made attribute for duplicating node in dropEvent.
The solution is to add a listener to your element <p:tree>
:
<p:tree listener="#{managingBean.onDragDrop}" />
Then you need to re-create the node at the original location, duplicating it in your reverse method:
public void onDragDrop(TreeDragDropEvent event) {
TreeNode dragNode = event.getDragNode();
TreeNode dropNode = event.getDropNode();
int dropIndex = event.getDropIndex();
// Logic to repopulate initial Tree element
}
And don't forget to re-paint the tree
+1
Thrax
source
to share