Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
665
Problem in Drag ang drop with WebTree
posted

Hi,

I have used a webtree,its working fine with child nodes but i have a broblem its not working with sibling nodes.

For ex,

 My Root node is Root1,It having 3 child nodes Parent1,Parent2&Parent3.The Parent nodes also have a child nodes.When i drag the Parent3 node and drop between Parent1 and Parent2 .its become a child of Parent1 but i  want its become a sibling node of Parent1 node.

Can anyone help me..

  • 7694
    posted

    Hello,

    Well actually what happens is that on the client a NodeDrop event is fired and you can customize whether a node becomes a child or a sibling of the destionation node there. For example, please take a look at the following sample

    There you will see the following code that actually makes the node a child of the destination node

            function UltraWebTree1_Drop(oTree, oNode, oDataTransfer, oEvent){
    var sourceNode = oDataTransfer.sourceObject;
    if(!oNode.isChildOf(sourceNode))
    {
    oNode.addChild(oDataTransfer.dataTransfer.getData("Text"));
    oNode.setExpanded(true);
    if(sourceNode)
    sourceNode.remove();
    }
    return false;
    }

    So I believe starting from this sample and tweaking the Drop even will lead you to the right path (e.g. not use addChild for the destionation node, but rather for its parent)