Drag&Drop - Drag Items from Table into Tree

Hi,

I have a Table component which displays Child objects.

I also have a Tree component which display Parent and Child objects belonging to the Parent.

I would like to drag a Child object from a Table and Drop it into the Parent of the Tree.

Are there any examples or solutions for Drag&Drop using Tables and Tree Components?

Thanks for the help.

Regards,
Lokesh

HI!

You can see an example in Access Groups screen. We can drag users and drop them into groups.
Check code of screen controller (GroupBrowser) or see this example: cuba-platform/sample-drag-drop.
Also check vaadin manual: https://vaadin.com/docs/v7/framework/advanced/advanced-dragndrop.html.

Thanks for your help

Hi,

Any idea on how to drag and drop an object in a empty location. I am using Tree as Drop location. For example, what if I want to drop an object in an Empty Tree or target == null.

Regards,
Lokesh

Could you clarify your question? Do you want to drop entity to the Tree which doesn’t contain data?
DragAndDropEvent event is always invoked if any data was dragged and dropped on it. So, you can handle this case in drop method.

vTree.setDropHandler(new DropHandler() {
    @Override
    public void drop(DragAndDropEvent dropEvent) {
        // do logic
    }

    @Override
    public AcceptCriterion getAcceptCriterion() {
        // do logic
    }
});

Hi,

I figured it out.

Thanks