-
8 Oct 2009 11:09 PM #1
TreePanel DND without removing node
TreePanel DND without removing node
Hi, just started to play with ext gwt, quite fun.
I have a probably very simple question about dnd:
I'm trying to make a drag'n'drop work from a TreePanel (to a TreeGrid).
It works nice except that the nodes being dragged from the source
are removed (which is normal in most cases). However I'd like them
to stay since I use the tree as a 'palette' of actions.
I'm assuming there is som simple setting to perform this, but am unable
to find it. any tips?
Thanks a lot // Bjorn
-
13 Oct 2009 3:36 AM #2
Define the dropTarget like so:
ie. the setOperation method should be used.Code:DropTarget target = new DropTarget(xxx) { @Override protected void onDragDrop(DNDEvent event) { Info.display("MessageBox", "DND event occured"); } }; target.setOperation(Operation.COPY) ;
note you'll have to import com.extjs.gxt.ui.client.dnd.DND.Operation ;
-
13 Oct 2009 9:15 AM #3
Works perfectly! Thanks for the answer, I didn't see
this option before.
-
13 Oct 2009 4:51 PM #4
You can also handle this at the source level if you want all targets not to remove items by overriding the TreePanelDragSource.onDragDrop
Code:TreePanelDragSource source = new TreePanelDragSource(treePanel) { @Override protected void onDragDrop(DNDEvent event) { // Do nothing on drop - prevents removal of tree items } }
-
22 Feb 2011 10:40 PM #5
setOperation() for Droptarget is not working
setOperation() for Droptarget is not working
Hi All,
I am new to GXT and in application i am using DragSource and DropTarget classes.
by default Operation.MOVE is set while DragNDrop but i have set Operation.COPY in DropTarget but its not working as COPY still its removing the source from DragSource
please find the code below:
DragSource source = new DragSource(html) {
@Override
protected void onDragStart(DNDEvent event) {
event.setData(html);
event.getStatus().update(El.fly(html.getElement()).cloneNode(true));
Info.display("DragSource", "Dragging kpis"+event.getOperation());
}
};
source.setGroup("Library");
******
DropTarget target = new DropTarget(center) {
@Override
protected void onDragDrop(DNDEvent event) {
super.onDragDrop(event);
Html html = event.getData();
Info.display("DropTarget", "Dropping kpis"+event.getOperation());
center.add(html);
}
};
target.setOperation(Operation.COPY);
target.setGroup("Library");
target.setOverStyle("drag-ok");
here "center" is ContentPanel
please reply................Last edited by vinaysu; 22 Feb 2011 at 10:42 PM. Reason: spelling check


Reply With Quote