I have a tree that I want to be able to drop filenames onto by dragging from the Windows file manager - ie from "ouside" the app. Since I am not dragging an Ext DDObject, the drop goes unrecognised by the tree beforenodedrop and nodedrop events.

Now, e.getTarget() returns the DOM element (either text or image depending upon whether I drop onto the node text or the node icon). What I need to do then is to work out which tree node I am dropping onto but I cant see how to work backwards from the dom node to the tree node.

I tried adding a node reference to the treenode.UI when the node is created but I need to work more on that to get it to work reliably.

Is there a simpler way to either get the tree node object to recognise the external drag, or to find out the treenode from the dom node? Or some other completely different way?

Thanks,
Murray

16 Mar 2011, 4:15 PM

murrah

Maybe create a drag object from my dom element ondrop listener and relay it somewhere so the tree ondrop event recognises it? Hmmmm - not sure how to do that either. Just thinking out loud - will investigate.

There's no check for leaf/non-leaf nodes or files/directories. It's just a quick and dirty one to demonstrate dragging onto a tree.

17 Mar 2011, 11:55 AM

murrah

Makana, you are a genius! Thank you!

The piece of information I was missing was that the tree node id was part of the dom at a higher level. So to make what Makana said a bit clearer:

PHP Code:

// Go back up the dom 3 levels from the dom node that fired the drop event
var domNode = e.getTarget('.x-tree-node-el', 3, true);
// Ask for the item with the attribute 'tree-node-id' in the 'ext' namespace which is actually the tree node id
var treeNodeId = domNode.getAttribute('tree-node-id', 'ext');
// Use that id to get the tree node
var treeNode = tx.tree.single.getNodeById(treeNodeId);

Fantastic. Thanks!

Murray

17 Mar 2011, 11:59 AM

murrah

I want to mark this as Solved but the Go Advanced button throws a JS error! "PATHS not found"