I do apologize in advance if my question has already been answered or if I am just making a dumb mistake. However, I have been using this plugin for a while and have thoroughly enjoyed its use so if someone knows what I am doing wrong, I would be most grateful for a solution.
So here is the background, I have created a cell table that has a custom AbstractCellTableBuilder provided. I'm not sure if this may interfere with the DnD. I do this because I have created my own table tree implementation. I provide the root level of data with setRowData(...) and my table builder can then create the children and such. Now I have one column that I want the user to be able do grab-drag-drop in order to move the rows around. Here is the relevant code, I have tried to leave out anything that isn't.
I create the column for use in the buildRowImpl(...) method of the table builder
column= new DragAndDropColumn<Code, ImageResource>(new ImageResourceCell()) {
@Override
public ImageResource getValue(Code object) {
return GeneralIcons.INSTANCE.twoLines12h();
}
};
// initialize drag
DraggableOptions draggableOptions = column.getDraggableOptions();
draggableOptions.setHelper($(Templates.INSTANCE.outerHelper().asString()));
draggableOptions.setOpacity((float) 0.8);
draggableOptions.setCursor(Cursor.MOVE);
draggableOptions.setRevert(RevertOption.ON_INVALID_DROP);
draggableOptions.setCancel("select");
draggableOptions.setOnDragStop(new DragFunction() {
@Override
public void f(DragContext context) {
placeHolder.remove();
oldEl = null;
}
});
//Initialize drop
DroppableOptions droppableOptions = column.getDroppableOptions();
droppableOptions.setAccept(new AcceptFunction() {
@Override
public boolean acceptDrop(DragAndDropContext context) {
return true;
}
});
droppableOptions.setOnDrop(new DroppableFunction() {
@Override
public void f(DragAndDropContext context) {
onDrop(context);
}
});
droppableOptions.setOnOver(new DroppableFunction() {
@Override
public void f(DragAndDropContext context) {
Element el = context.getDroppable();
if (oldEl != null && oldEl.equals(el))
return;
else
oldEl = el;
if (el != null)
placeHolder.insertBefore(el.getParentElement().getParentElement());
}
});
droppableOptions.setTolerance(DroppableTolerance.POINTER);
Then in the buildRowImpl(..) method I add the cell to the table with the column like this
TableCellBuilder td = row.startTD();
renderCell(td, createContext(2), column, rowValue);
td.endTD();
And I add the drag handlers to the table, but it is never firing. Am I forgetting to do something?
cellTable.addDragStartHandler(new DragStartEventHandler() {
@Override
public void onDragStart(DragStartEvent event) {
handleOnDragStart(event);
}
});
If you need any more information please let me know. I have used the Dnd cell table before like in the example, but never with a custom table builder, so I am not sure if that affects the DnD behavior.
Much Thanks,
Will