I need to implement drag and drop for cells in CellTable . Following the MobileWebApp example, I implemented a custom draggable cell:
public class DraggableCell extends AbstractCell<ProductProxy>{ interface Templates extends SafeHtmlTemplates { @SafeHtmlTemplates.Template("<div draggable=\"true\">{0}</div>") SafeHtml simpleTextTemplate(String text); } protected Templates templates = GWT.create(Templates.class); public DraggableCell() { super("dragstart"); } @Override public void render(Context context, ProductProxy value, SafeHtmlBuilder sb){ sb.append(templates.simpleTextTemplate(value.getName())); } @Override public void onBrowserEvent(Context context, Element parent, ProductProxy value, NativeEvent event, ValueUpdater<ProductProxy> valueUpdater) { final Integer cursorOffsetX = 0; final Integer cursorOffsetY = 0; if ("dragstart".equals(event.getType())) {
I use a new element for the drag and drop image (in MobileWebApp they just use the parent element), but, unfortunately, the image does not appear during drag and drop. I thought that perhaps the new element needs to be bound to the DOM first, so I created a helperPanel and bound the element to it:
DOM.getElementById("dragHelperPanel").appendChild(element);
This works fine in Firefox 6, but no luck in Chrome (using the latest stable version), so maybe this is not the right way to do this. Any ideas? Thanks!
source share