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

Drop In-Between Nodes Client-side

2 Answers 66 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Joe
Top achievements
Rank 2
Joe asked on 18 Jan 2008, 11:55 PM
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 Answers, 1 is accepted

Sort by
0
Dimitar Milushev
Telerik team
answered on 21 Jan 2008, 10:03 AM
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
0
Joe
Top achievements
Rank 2
answered on 21 Jan 2008, 09:17 PM
This is exactly what I needed.

Thanks!
Tags
TreeView
Asked by
Joe
Top achievements
Rank 2
Answers by
Dimitar Milushev
Telerik team
Joe
Top achievements
Rank 2
Share this question
or