背景:sencha ext-gwt 3.0 (beta3)。我正在使用dnd让用户重新安排一棵树,一次一个元素。我可以轻松获得拖动的元素,但没有找到如何获得放置目标。这是我的代码:
final TreeDropTarget<IMyModel> target = new TreeDropTarget<IMyModel>(mytree);
target.setAllowSelfAsSource(true);
target.setAllowDropOnLeaf(true);
target.setFeedback(DND.Feedback.BOTH);
target.addDropHandler(new DndDropEvent.DndDropHandler()
{
@Override
public void onDrop(final DndDropEvent event)
{
IMyModel dragged = mytree.getSelectionModel().getSelectedItem();
// TODO get the drop target element!
}
});
答案 0 :(得分:1)
这对我有用:
target.addDropHandler(new DndDropHandler() {
@Override
public void onDrop(DndDropEvent event) {
final TreeNode<MyModel> item = source.getWidget().findNode(event.getDragEndEvent().getNativeEvent().getEventTarget().<Element> cast());
MyModel newParent = item.getModel();
}
});
答案 1 :(得分:0)
请参阅可用的GXT 3.0测试版示例here