PDA

View Full Version : TreeNode Drag&Drop Source



flumueller
19 Sep 2007, 10:42 PM
Hi there!
How can I find out the source node from a dragged node?

http://www.net-arts.ch/ext.jpg
In this example the "home" node. (i drag the subnote projects from home to downloads)

My code:


tree.on('nodedrop', function(e) {
var nDepth = e.dropNode;
var tDepth = e.target;
});


I know already how can I get the drop node and the target node but not the source node (where the node come from).

Thanxx

Animal
19 Sep 2007, 11:37 PM
http://extjs.com/deploy/ext/docs/output/Ext.tree.TreePanel.html#event-nodedrop

flumueller
20 Sep 2007, 12:20 AM
thx, but it was nit possible to find the "source node" with the propertie "source".
Maybe u can make a example?

Thanxx

Animal
20 Sep 2007, 12:43 AM
You mean the original DOM node dragged?

You want to create a new TreeNode?

What you need is the data peoperty of the event.

This is the data set by getDragData, and can be anything you set up in your implementation of getDragData.

You create your new treeNode from this data.

flumueller
20 Sep 2007, 1:15 AM
Sorry for my bad english:)

I don't want create a new TreeNode.

In my example:
If i drag the "projects" node from the "home" folder into the "downloads" folder i need the following informations:

i want to get the "home" node. That means the parent from "projects" before i dragged
it into "downloads". (I mean something like e.sourceNode - where the node come from).


tree.on('nodedrop', function(e) {
var nDepth = e.dropNode;
var tDepth = e.target;
});

U know what i mean?

Animal
20 Sep 2007, 1:24 AM
Stop in that function in Firebug, and poke around in e.data

flumueller
20 Sep 2007, 1:31 AM
I did this already but i didn't found this propertie:(
Only targetNode, dragNode, parentNode, nextSibling, previousSibling, first and last..
But not the parentNode before drop.

http://www.net-arts.ch/ext1.jpg

Animal
20 Sep 2007, 1:53 AM
So, those handles...

When you hover over them, the HTML highlights on the page. They should be the source DOM nodes.

That is what is done by the default getDragData function in DragZone.

If you implement your own, you can put any data you want in there.

You really need to implement getDragData and collect the data you need yourself. The default implementation doesn't really know what you are dragging.

Animal
20 Sep 2007, 1:57 AM
It looks like the node property there is exactly what you are wanting!

flumueller
20 Sep 2007, 2:06 AM
The node property is the "drag node" right (in my example "projects")?. But i need the parent node before i drop the "projects" node. (-> "home").

Animal
20 Sep 2007, 2:16 AM
The node has a parentNode property like all nodes which are actually in a Tree.

flumueller
20 Sep 2007, 3:45 AM
Yes, but if i use the parentNode i call already the new parent node. That means the target! not where the node come from..

Animal
20 Sep 2007, 4:22 AM
I give up. I have no clue what you need.

flumueller
20 Sep 2007, 4:39 AM
Ok, no problem;) But thanxx for ur help

ext_new_user
6 Nov 2007, 6:26 AM
Hi
I am not sure it will work right but i think you need to call beforenodedrop event.