Welcome Guest Search | Active Topics | Sign In | Register

Clientside Function on Treeview DnD Options
JeanR
Posted: Monday, December 19, 2011 8:54:24 AM
Rank: Newbie
Groups: Member

Joined: 11/30/2011
Posts: 8
Hi Guys,

I've managed to sort out most of my previous problems - so thanks for that. I now have two more things I would like to achieve (will post as seperate topics). Let me explain the scenario - I build up a "document library" treeview (in SharePoint 2010). I set certain properties on each node while I'm building it of which one is myNode.Value to which I assign the url of the file/folder location in SharePoint.

Now my treeview allows for drag-n-drop and the functionality of that I've completed. My problem however is this - on the treeview drag-n-drop is allowed no matter the type of the item. In other words "files" can be dropped into "folder" but also into other "files" because the treeview structure doesn't differentiate and just sees a node. What I want to do is to do some clientside/javscript function that fires before the server side OnItemMoved event. In this I want to be able to access the myNode.Value atrribute of the "Target" node so that I can check if it is a "file" or a "folder" and then allow/prevent the actuall drop to take place depending on the outcome of that test.


I'm guessing I will have to use ClientSideOnDragDrop. But I have no clue how to access the node details of the target etc. Some help on this will be highly appreciated!

Kind Regards
Jéan
eo_support
Posted: Monday, December 19, 2011 10:45:34 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

You would use ClientSideOnDragOver and ClientSideOnDragDrop. These are two functions that you would provide and all the necessary information are passed to you as function arguments:

http://www.essentialobjects.com/doc/1/jsdoc.public.handlers.treeview_dragdrop_handler.aspx

For example, the following code does not allow dropping if the target node's text is "No Drop Zone!":

Code: HTML/ASPX
<eo:TreeView  ClientSideOnDragDrop="drop_handler" ...>
.....
</eo:TreeView>


Code: JavaScript
function drop_handler(treeview, srcNode, destNode, newIndex)
{
    if (destNode.getText() == "No Drop Zone!")
        return false;
}


The key points are:
1. The srcNode and destNode are passed to your function through function arguments;
2. You return false from your function to cancel the drag drop;

Hope this helps. Please feel free to let us know if you still have any questions.

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.