Handling Drag and Drop Events in Gxt TreeGrids
The Ext GWT framework offers some rather sophisticated support for drag and drop in GWT applications. However dealings with drag and drop in TreeGrids can be complicated at times, since only limited documentation apart from the examples in the showcase is provided.
Here some information, how it can be controlled, where an item can be inserted in a TreeGrid.
This class can be utilized to handle drop events on a TreeGrid. It can be assigned to a TreeGrid through its constructor new TreeGridDropTarget(treeGrid).
This method can be overridden in TreeGridDropTarget to achieve custom rules for where a 'drop' is allowed.
This is the parameter of the showFeedback method. Its attributes can be used to determine an appropriate feedback.
Can be cast to TreeGridDragSource. Points to the source tree grid for the drop.
Can be cast to TreeGridDropTarget. This should point to the drop target triggering the method.
Can be cast to List<?>. Points to the items, which are to be dropped.
Can be cast to TreeStoreModel. Points to a specific item, which is to be dropped.
Through the method getModel(..) of the TreeStoreModel the actual item in the drag source can be accessed (As a BaseTreeModel).
Points to a dom element where the drag is to take place. If it's currently over a TreeNode, it can be found through:
TreeNode n = this.getTreeGrid().findNode(event.getTarget());
Finally, if the user feedback should be delivered, that it is illegal to drop the node at the current location, the following commands can be added to the overridden showFeedback(..) method:
If the default feedback shall be delivered, the overridden method should be called through calling super.showFeedback(event);.
Sibling Reordering DND Tree (Sencha Forum) Check here for methods to override for TreeGridDropTarget