Drop In-Between Nodes Client-side

3 posts, 0 answers
  1. Joe Hakooz
    Joe Hakooz avatar
    65 posts
    Member since:
    Dec 2007

    Posted 18 Jan 2008 Link to this post

    Hi,
    Is drop in-between nodes possible on the client side? I can't seem to find any documentation on it, and the online example doesn't work if client-side is checked...
    http://www.telerik.com/demos/aspnet/prometheus/TreeView/Examples/Functionality/DragAndDropNodes/DefaultVB.aspx

    If so, can you point me in the right direction as far as an example?

    Thanks
  2. Dimitar Milushev
    Admin
    Dimitar Milushev avatar
    555 posts

    Posted 21 Jan 2008 Link to this post

    Hi Joe Hakooz,

    The example does not currently take into account the drop position. We will make sure to update the example so it shows how to accomplish this. Below is a modified version of the 'clientSideEdit' plus two helper functions. Replace the original 'clientSideEdit' of the example with this code and drag & drop between nodes should work properly.

    function clientSideEdit(sender, args)  
    {  
        var destinationNode = args.get_destNode();                                        
          
        if(destinationNode)  
        {                 
            var firstTreeView = $find('RadTreeView1');  
            var secondTreeView = $find('RadTreeView2');  
          
            firstTreeView.trackChanges();  
            secondTreeView.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);                                                        
                if(args.get_dropPosition() == "above")  insertBefore(destinationNode, sourceNode);  
                if(args.get_dropPosition() == "below")  insertAfter(destinationNode, sourceNode);  
            }  
            destinationNode.set_expanded(true);  
            firstTreeView.commitChanges();  
            secondTreeView.commitChanges();  
        }  
    }  
     
    function insertBefore(destinationNode, sourceNode)  
    {  
        var destinationParent = destinationNode.get_parent();  
        var index = destinationParent.get_nodes().indexOf(destinationNode);  
        destinationParent.get_nodes().insert(index, sourceNode);  
    }  
     
    function insertAfter(destinationNode, sourceNode)  
    {  
        var destinationParent = destinationNode.get_parent();  
        var index = destinationParent.get_nodes().indexOf(destinationNode);  
        destinationParent.get_nodes().insert(index+1, sourceNode);  
    }                 
     


    Sincerely yours,
    Dimitar Milushev
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Joe Hakooz
    Joe Hakooz avatar
    65 posts
    Member since:
    Dec 2007

    Posted 21 Jan 2008 Link to this post

    This is exactly what I needed.

    Thanks!
Back to Top