Search code examples
gwtdatagriddrag-and-dropgwtquery

GWT Drag and Drop within tree and between tree grids


We're using GWT and We're required to create two drag and drop tree grids. Each tree contains parents and children (max two level for now). Here's what we need to be able to do:

Use cases

  • Drag a parent from one tree grid to the other.
  • Drag a parent 1 to parent 2 (1 will become child of 2, and all 1's children will become children of 2) -> please don't ask :D
  • Drag a child from one parent to another (within the same tree grid)
  • Drag a child to top level within the same tree grid (child will become a parent)
  • Drag a child to the other tree grid with two options
    1 - Top level - child from tree 1 will become a parent on tree 2.
    2 - Parent - Child from tree 1 will become child of a parent on the tree grid 2.

If this doesn't make much sense, we don't have the full context yet, so that's all we know.

Problem

We can drag on the same tree grid. If the row we want to drag the cell to is hidden, we set the scroll to true, so that the grid scrolls when the user is dragging inside it. Something like so:

private void setDraggableOptions(DragAndDropColumn<?, ?> column) {
    // retrieve draggableOptions on the column
    DraggableOptions draggableOptions = column.getDraggableOptions();
    draggableOptions.setScroll(true);
    // use template to construct the helper. The content of the div will be set
    // after
    draggableOptions.setHelper(HelperType.CLONE);
    // opacity of the helper
    draggableOptions.setOpacity((float) 0.8);
    // cursor to use during the drag operation
    draggableOptions.setCursor(Cursor.MOVE);
    // set the revert option
    draggableOptions.setRevert(RevertOption.ON_INVALID_DROP);
    // prevents dragging when user click on the category drop-down list
    draggableOptions.setCancel("select");
    column.setDraggableOptions(draggableOptions);
}

Now the problem is, setting the tree grid to scroll, the user will never be able to drag the object to the second tree as the scroll will try to keep the object always inside the grid.

We're using the gwtquery-plugins

Is there any idea to work around this? Thank you very much in advance.


Solution

  • See my response to your question here