Search code examples
javagwtdrag-and-dropgxt

Value from the dragsource is removed when it is dragged in GXT


I am able to drag and drop an item from dragsource to droptarget in GXT. When I drag an item from source to target, it is removed from the source. Can you please help me to keep the value in source and target.

  DragSource source = new DragSource(html) {
    @Override
    protected void onDragStart(DndDragStartEvent event) {
      super.onDragStart(event);
      event.setData(html);
      event.getStatusProxy().update(builder.toSafeHtml());
    }
  };

DropTarget target = new DropTarget(dropContainer) {
    @Override
    protected void onDragDrop(DndDropEvent event) {
      super.onDragDrop(event);
      HTML html = (HTML) event.getData();
      dropContainer.add(html);
    }
  };

Solution

  • You can set the operation type of the target as MOVE or COPY or whatever is required.

    dropTarget.setOperation(Operation.COPY); // This will copy the value from source to target.