Home - Forums-.NET - FlyTreeView (ASP.NET) - Drag item to root

FlyTreeView (ASP.NET)

Technical support and KB related to the FlyTreeView control

This forum related to following products: FlyTreeView for ASP.NET

Drag item to root
Link Posted: 30-Aug-2006 20:16
Hi,

Using Freetreeview for asp2.0, I want to be able to drag a node to the root of the tree.
Sample:

node1
--node1-1
--node1-2
node2
--node2-1
--node2-2
----node2-2-1
----node2-2-1

(drag node2-2-1 to root -->).
Result:

node1
--node1-1
--node1-2
node2
--node2-1
--node2-2
----node2-2-1
node3 (former node2-2-1)

As work around I tried to create a div just above the treeview, drag items to it and have the item client side added to the treeview. No luck so far. any hint?
Link Posted: 30-Aug-2006 20:34
hmm ok, reading this topic: http://www.9rays.net/forums/viewtopic.php?t=843 I understand that it cannot be doen because you cannot add nodes to the root on the client side.

Can you think of a way to re-route this to the server side?
Link Posted: 30-Aug-2006 21:44
Haha nice... conversation with me, myself and... I

Anyways.

I read http://www.9rays.net/forums/viewtopic.php?t=1045 and after updating to the latest version I got it to work: created a dropzonde just above the tree where root-nodes can be vreated.

The thing I can't get to work is setting the image for the new node.
I tried it this way:
- newNode.ImageUrl = \"$office2003_folder\";
- newNode.Tag = \"dragfolder\";
- newNode.DragDropName = \"dragfolder\";
- newNode.DragDropAcceptNames = \"dragfolder,dragitem\";

No luck here. Tips?

The code above work for creating a new node. The mentioned types \"dragfolder\" and  \"dragitem\" came dragged-in from some listboxes to my dragzone..
But I still have trouble when the dragged item is a node from the treeview.
My code:

if (flytreeview_dragObject.value instanceof CFlyTreeNode)
{
    treeview.addNode(flytreeview_dragObject);
}

The exception throwd is: Microsoft JScript runtime error: '_fv32' is null or not an object

There mus be another way

please..........
Link Posted: 31-Aug-2006 15:32
Regarding this code:
if (flytreeview_dragObject.value instanceof CFlyTreeNode)
{
treeview.addNode(flytreeview_dragObject);
}


Notice that not flytreeview_dragObject is CFlyTreeNode but flytreeview_dragObject.value. So your code should look like the following:
if (flytreeview_dragObject.value instanceof CFlyTreeNode)
{
treeview.addNode(flytreeview_dragObject.value);
}



I think I've replied in my previous message regarding client-side properties like DragDropName.
Link Posted: 01-Sep-2006 02:18
Still no luck.

To be clear: I drag a node from my treeview to adiv, like in the demo app the dropzone. But I do not want the dragged node removed, I want to make it a root-node. This could be a work-around for dragging nodes to the root.

The errer I get is:

Error occurred:
Invalid access to function to be used with node without owner treeview.
Link Posted: 01-Sep-2006 08:43
yes the reason is that the node should have no parent before addNode() call.

The problem is that CFlyTreeNode.clone() isn't still public.
We had a small meeting here. The clone method will be public. Product will be tested for a while and get published in several hours.

So finally you should try to use (download the latest build)

if (flytreeview_dragObject.value instanceof CFlyTreeNode)
{
treeview.addNode(flytreeview_dragObject.value.clone());
}
Link Posted: 04-Sep-2006 01:47
you are the best! Thanx for the good work!
Link Posted: 04-Sep-2006 01:54
small problem though....

If the dragged node contains childnodes, it....disappears

Single node works ok.

edit: when I drag a node with a chuild node, the dragged node disappears, while the childnode gets added to the root. When there are multiple child nodes, only the last one survives.
Link Posted: 04-Sep-2006 09:44
So what are you doing finally:
Do you create a node with children and then try to add them?

Could you please provide me with the detailed source code for what you do?

We'll then try to create a copy of your task and push it into samples project.

Thanks.
Link Posted: 04-Sep-2006 20:22
What I am trying to do is find a way to drag a (populated) node from soemwhere in the tree to the root of the tree.
To accomplish this I created a \"dropzone\" just above the treeview, where I drop the (populated)  node. At that point I do this:

var treeview = CFlyTreeView.getInstanceById(\"ftvMenu\");
if (flytreeview_dragObject.value instanceof CFlyTreeNode)
{    
   treeview.addNode(flytreeview_dragObject.value.clone());
}

result: if it was a single non-populated node: it gets added to the root.
If it was a populated node, then the very last subnode get added to the root of the targettree. The rest disappears.