Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Robin on Dec 05, 2008 09:09
open dhtmlx forum
Dragging a node from Tree to TreeGrid

Hi,

I am dragging a node from Tree to TreeGrid and it is adding that node as last node to the selected parent in Treegrid. I want to add that dragged node as first child of parent in Treegrid. Is is possbile? If yes, please suggest a way.

Thanks in advance.
Answer posted by Support on Dec 05, 2008 09:37
There is no simple way to achieve such functionality. 
You can use 

mygrid.setDragBehavior("complex");
mygrid.attachEvent("onDrag",function(sid,tid){
    ...
    mygrid.setDragBehavior("complex-next");
    mygrid.dragContext="sibling";
    mygrid.dragContext.alfa=true;
    ...
    return true;
})

Answer posted by Robin on Dec 05, 2008 13:19

It didnt work for me. So I used alternate way. I created new method to move up the newly added row.

function moveRowOnTop(rowId)

{

    try

    {

        var strParentId = mygrid.getParentId(rowId);

        var arrTemp = mygrid.getAllSubItems(strParentId);

        if(arrTemp != "")

        {

            arrTemp = arrTemp.split(",");

            for(var i = 0; i < arrTemp.length; i++)

           {

                mygrid.moveRowUp(rowId);

           }

        }

   }

  catch(e)

  {}

}

 

Anyways thanks for ur reply.