I basically check to see if the item being dragged has the same parentId as the target so the reordering takes places within the same level nodes. When I do this, the only valid drop area was the area between the parent node and the first child in the node. After the drop, the node is moved as a new node outside of the parent node. It basically becomes a sibling of the parent. Any help would be much appreciated.
Code:
TreeDropTarget<BaseDto> target = new TreeDropTarget<BaseDto>(tree) {
@Override
public void showFeedback(DndDragMoveEvent event) {
final com.sencha.gxt.widget.core.client.tree.Tree.TreeNode item = getWidget().findNode(event.getDragMoveEvent().getNativeEvent().getEventTarget().<Element> cast());
if (item == null && activeItem != null) {
clearStyle(activeItem);
}
BaseDto dragged = (BaseDto)tree.getSelectionModel().getSelectedItem();
BaseDto newLocation = ((com.sencha.gxt.widget.core.client.tree.Tree.TreeNode<BaseDto>) item).getModel();
String newParentId = newLocation.getId();
String draggedParentId = ((SchoolNode)dragged).getParentID();
String oldParentId = ((SchoolNode)dragged).getParentID();
if (newParentId != oldParentId) {
Insert.get().hide();
event.getStatusProxy().setStatus(false);
System.out.println("Bad drop");
return;
}
else
System.out.println("Good drop");
boolean append = feedback == Feedback.APPEND || feedback == Feedback.BOTH;
boolean insert = feedback == Feedback.INSERT || feedback == Feedback.BOTH;
if (item == null) {
handleAppend(event, item);
} else if (insert) {
handleInsert(event, item);
} else if ((!getWidget().isLeaf((BaseDto) item.getModel()) || this.isAllowDropOnLeaf()) && append) {
handleAppend(event, item);
} else {
if (activeItem != null) {
clearStyle(activeItem);
}
status = -1;
activeItem = null;
appendItem = null;
Insert.get().hide();
event.getStatusProxy().setStatus(false);
}
}
};