This is a migrated thread and some comments may be shown as answers.

Client side Validation for Drag Drop in Radtreeview

1 Answer 118 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
chithuraj
Top achievements
Rank 1
chithuraj asked on 17 Sep 2009, 12:58 PM

Hi,
I have a radtreeview which is having 3 nodes say for example,

There are 3 parent nodes namely A,B,C each having 4 child nodes, I am doing client site drag and drop what ever mentioned in telerik demo.
My problem is the child nodes in parent node A should not be drag and drop to Parent node B.
Again parent node A should not be drag and drop to any other child nodes of B or C.

Here is my code what i am doing for drag and drop on client side:

function onNodeDragging(sender, args)  
            {  
                var target = args.get_htmlElement();      
                  
                if(!target) return;  
                  
                if (target.tagName == "INPUT")  
                {          
                    target.style.cursor = "hand";  
                }  
            }  
              
            function onNodeDropping(sender, args)  
            {              
                var dest = args.get_destNode();  
                if (dest)  
                {  
                    clientSideEdit(sender, args);                  
                    args.set_cancel(true);  
                    return;  
                    dropOnTree(args);  
                }  
            }  
              
            function dropOnTree(args)  
            {  
                var text = "";  
 
                if(args.get_sourceNodes().length)  
                {      
                    var i;  
                    for(i=0; i < args.get_sourceNodes().length; i++)  
                    {  
                        var node = args.get_sourceNodes()[i];  
                        texttext = text + ', ' +node.get_text();  
                    }  
                }  
            }  
              
            function clientSideEdit(sender, args)  
            {  
             var destinationNode = args.get_destNode();                                   
             if(destinationNode)  
             {              
                    var firstTreeView = $find("<%=RadTreeView1.ClientID %>");  
                    firstTreeView.trackChanges();  
                    var sourceNodes = args.get_sourceNodes();  
                    for (var i = 0; i < sourceNodes.length; i++)  
                    {  
                       var sourceNode = sourceNodes[i];  
                       sourceNode.get_parent().get_nodes().remove(sourceNode);                  
                        if(args.get_dropPosition() == "over")  
                        { destinationNode.get_nodes().add(sourceNode);}   return GenerateNodesAsXML();  
                          if(args.get_dropPosition() == "above")     insertBefore(destinationNode, sourceNode);  
                            if(args.get_dropPosition() == "below")     insertAfter(destinationNode, sourceNode);  
                    }  
                   destinationNode.set_expanded(true);  
                   firstTreeView.commitChanges();  
             }  
            }  
              
            function insertBefore(destinationNode, sourceNode)  
            {  
             var destinationParent = destinationNode.get_parent();  
             var index = destinationParent.get_nodes().indexOf(destinationNode);  
             destinationParent.get_nodes().insert(index, sourceNode);  
               
             return GenerateNodesAsXML();  
            }  
 
            function insertAfter(destinationNode, sourceNode)  
            {  
             var destinationParent = destinationNode.get_parent();  
             var index = destinationParent.get_nodes().indexOf(destinationNode);  
             destinationParent.get_nodes().insert(index+1, sourceNode);  
               
             return GenerateNodesAsXML();  
            } 

Please help me on this

Any help will be appreciated.

Thanks in advance.
Vinod

1 Answer, 1 is accepted

Sort by
0
Robert
Top achievements
Rank 1
answered on 21 Oct 2009, 08:02 PM
Vinod,

I have a similar predicament and have tried several approaches to show the user which nodes (and spaces in between nodes) he can drop a dragged node onto.  But it appears impossible (or insanely unwieldy) with the current version of the RadTreeView.

Robert
Tags
TreeView
Asked by
chithuraj
Top achievements
Rank 1
Answers by
Robert
Top achievements
Rank 1
Share this question
or