Home - Forums-.NET - FlyTreeView (ASP.NET) - Cancel drop event

FlyTreeView (ASP.NET)

Technical support and KB related to the FlyTreeView control

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

Cancel drop event
Link Posted: 13-Oct-2006 02:09
Hi,

I want to cancel the drop event if the droped new node has the same text as the node is was dropped under.

In the function ftvMenu_OnDrop(target, event) method I can see the text for the target node via event.srcElement.innerText
Where is the droped value?
Link Posted: 14-Oct-2006 02:32
The value of dragged object is in
flytreeview_dragObject.value

If you use treenode then it will look like the following:

flytreeview_dragObject.value.getValue()
Link Posted: 14-Oct-2006 02:33
Also, you should return false to cancel drop.
Link Posted: 15-Oct-2006 20:03
works! Cool.

Now.....just a thought....if I did the check (is name of targetnode the same as name of dropped childnode) on treeview_OnDragOver, can I show the cannot-drop-icon (like when drop-accept names do not match)?
Link Posted: 15-Oct-2006 23:43
You should probably use the OnDragOverJavascript handler and return false to deny drop (and show icon).

See http://www.9rays.net/asp.net_2/treeview/Doc_ClientEvents.aspx for details.
Link Posted: 16-Oct-2006 01:31
nice! Works.

One problem though...

I misread the functional design of the app; i thought a node with the same name cannot be created under an existing node. This not the case. It must be so that you cannot add the same node under a parentnode:

parent1
--child1
--child2
--child2 --> this one should not have been created.

So on drop, I need to find the parent of the node under witch I am dropping, an check if the same node is allready there.
Client side of course.

How do I find this parentnode? I thought of getting the current node with \"findByValue(nodeValue)\" but where do I find the value to search for?
Link Posted: 16-Oct-2006 02:03
ah solved that one. I allready have the target node...easy... Just loop through getChildNodes

but!

When I drop to root node, via the zone ;-) , GetChildnode failes, need to do GetNodes instead. How do I determine looking at the target node if this is the rootnode or not.
Link Posted: 16-Oct-2006 02:05
http://www.9rays.net/asp.net_2/treeview/Doc_ClientEvents.aspx :
[boolean] OnDropJavascript ([CFlyTreeNode] target, [event] event)

So target is a parent node. It is drop target.
You need to use it and call target.findAll(condition) or target.findByValue(..) (note: both return arrays).

P.S. Same for OnDragOverJavascript
Link Posted: 16-Oct-2006 02:13
done via this:  if (typeof target.getChildNodes == 'function')

if returns false, run the getNodes function.

I bit.....awkward..?


wait, there is a reply from you....
Link Posted: 16-Oct-2006 02:15
better condition for tree node
target instanceof CFlyTreeNode

and for treeview
target instanceof CFlyTreeView