Client side Validation for Drag Drop in Radtreeview

2 posts, 0 answers
  1. chithuraj
    chithuraj avatar
    18 posts
    Member since:
    Mar 2009

    Posted 17 Sep 2009 Link to this post

    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

  2. Robert
    Robert avatar
    253 posts
    Member since:
    Aug 2007

    Posted 21 Oct 2009 Link to this post

    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
Back to Top