PDA

View Full Version : Tree Drag and Drop - Get Data



ApolloX
3 May 2010, 1:07 AM
I've been working with the tree reordering drag and drop example found here:
http://www.extjs.com/examples/pages/dnd/reorderingtree.html

I've added a listener for the drop event as follows:

target.addDNDListener(new DNDListener() {
@Override
public void dragDrop(DNDEvent e) {
super.dragDrop(e);
}
});How do I access the two models associated with the drag event, so that I can update the data associated with the move? I'd like to update the model object I am moving and the parent 'folder' that it is being moved.

So far, one way to access the object being moved is via this method:

target.addDNDListener(new DNDListener() {
@Override
public void dragDrop(DNDEvent e) {
super.dragDrop(e);
final ModelData myModel = ((List<TreeStoreModel>)e.getData()).get(0).getModel();
}
});Two problems with this code though:
1) It's not very pretty leading me to believe I'm doing something wrong.
2) myModel.getParent() is null so I still don't have access to the folder the item is being moved too.

Can anyone advice?