Home - Forums-.NET - FlyTreeView (ASP.NET) - Server side event support

FlyTreeView (ASP.NET)

Technical support and KB related to the FlyTreeView control

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

Server side event support
Link Posted: 03-May-2007 18:31
I'm using the newest version of Treeview control and I'm writing an application where the program will populate the treeview with a directory in the server. The program consists of 2 treeviews where the first one contains the directories and the second one contains the files in the selected directory. The user can then drag the files from the 2nd treeview and drop it into another directory in the first treeview.  At this point the application will move the file from the original directory to the target directory.

What the server needs is the original files location (the directory) and the node(target directory) where the user drops the files to. With this information, the application can then actually move the files from the original to the target directory.

I'd used OnSelectedNodeChanged and OnNodeSelected event and didn't have good success. I put a breakpoint on the procedure (Flytreeview_onselectednodechange) to moinotr whether the event fires the way I want it.  Sometimes the event fired and most of the time they didn't. I ended up set the PostbackonClick so that each time the user clicks on a node it posts back to the server for proceessing. But it didn't help the drag drop protion.

Could you show me a way to capture the information when the user drop the files on to the treeview? Better yet, do you have any sample code that I can look at?

Thanks
Link Posted: 04-May-2007 03:02
Do you need to fire some server event immediately when the user drops a node onto some other node? I mean without page reload (postback).

Do you currently use the PostbackOnDropAccept to postback page  to handle client-side D&D operation?


From my point of view, you should better use the NodeMoved, NodeRemoved and NodeInserted  server events.

You can also store original node path in a node.Value property to retrieve it in the NodeInserted event.
You can also use node.Attributes[attrName] collection to store all the required information regarding your nodes.
Link Posted: 04-May-2007 10:11
Thanks! It works wonderfully .

However, I have one more question. After the user drags from the 2nd tree (contains the files of the selected directory) and drop it to the first tree (contains the directory tree), the 1st tree node automatically expands and creates a node under it with dropped file name. Is there a way to stop the treeview from expanding the node and show the new dropped file? I couldn't seem to find a event handle or object that I can check for this condition. It's kind of like Window Explorer that when you drop something to the directory it won't expand the directory node.

BTW, I'm using the NodeInserted and OnPopulateNode events and I also enable the PostbackOnDropaccept and PostbackOnClick events on the 1st tree.

Thanks.
Link Posted: 04-May-2007 11:20
Yes, FlyTreeView expands node when something is dropped on to it.

This is hardcoded action, so the only way from my point of view is to collapse node after it is expanded. But then you need to handle client-side node event (EXPANDED) and call node.collase().
Something like this.
Link Posted: 04-May-2007 12:21
I found one of this advice you gave in another post, will it work for my case?

Is Flytreeview_DragObject a global object? I couldn't find it's documentation anywhere.

From docs:
Quote:
[boolean] OnDropJavascript ([CFlyTreeNode] target, [event] event)
Fired when a dragObject is dropped onto treeview node (target). Return false to cancel the drop.  


To remove node from the source treeview and not let it add to the second treeview you should just modify your code to return false:

Code:
function flyTreeView1_OnDrop(target, event)
{
    flytreeview_dragObject.value.remove();
    return false;
}


When you call to flytreeview_dragObject.value.remove(); the node is removed from the treeview.
Link Posted: 05-May-2007 22:49
Here are some words regarding  flytreeview_dragObject :
http://www.9rays.net/asp.net_2/treeview/miscpages/doc/DragDrop.aspx

Anyway I cannot get how are you going to use it in your case.