Drag and Drop in only same level

Hi,
I have a requirement like,
i should able to do drag an item in same level only.
i.e, i have to implement d nd d functionality in a way so that i can arrange the nodes in an order of my wish but in the same level.

in below tree i have to do arrange the order of two parent nodes like pnode2 first nd pnode1 last and node2,node3,node4 in an order node3,node2,node4 (But in SAME LEVEL).

i should not drag node2 as a child of pnode2.

rootnode
pnode1
------node2
------node3
------node4
pnode2
-----node5
-----node6

dragBehaviour sibling and child are not enough to do this , i already tried.

How can i do this Can you please help me :slight_smile:

Please respond…

How can i do drag nd drop in the same branch in tree(do order the nodes in same branch)

Hi

tree.attachEvent("onDragIn", function(sId,tId,id,sObject,tObject){ var sParent = tree.getParentId(sId); var tParent = tree.getParentId(tId); return sParent==tParent });

Thanks for your reply Darya :slight_smile:

but i am unable to arrange pnode1,pnode2 in an order of my specific.

May be i didn’t understand you…
Try this:

tree.attachEvent("onDragIn", function(sId,tId,id,sObject,tObject){ var sLevel = tree.getLevel(sId); var tLevel = tree.getLevel(tId); return sLevel==tLevel });

Yeah thanks darya for your kind reply.

But still i am unable to achive my thing with ur code.
Let me explain you what exactly i need…

The view of my tree like:
rootnode
parent1
child1
child2
child3
child4
child5
parent2
child6
child7
child9
child10
parent3

So i need to give an option to the user to arrange the nodes according to his wish.
but there is some conditions like

1.He can move the nodes in only one branch. i.e, he can move child3 to below child4, that is child4 comes first nd child3 second.
2.He can’t move child1 into the child2 branch. but he can move child1 to below of child2 so that the order will be child2 nd child1 then child5.
3.And he can change the order of parents also like parent1 comes after parent2. like wise

I think u understood the thing :slight_smile:

I will wait for your reply.

Totally the thing is GIVING AN OPTION TO THE END USER TO CHANGE THE ORDER OF HIS TREE. but conditions apply :slight_smile:

Thanks,
Naresh Adla

Consider this tree please

The view of my tree like:
rootnode
----parent1
--------child1
--------child2
------------child3
------------child4
--------child5
----parent2
--------child6
--------child7
------------child9
------------child10
----parent3

I have tried some thing like this
customTree.attachEvent(“onDragIn”, function(sId,tId,id,sObject,tObject){
var sParent = customTree.getParentId(sId);
var tParent = customTree.getParentId(tId);
return ((sParent==tParent) && customTree.hasChildren(tId) == “”);
});
Working fine but i am unable to move parents because parents can have children riaght so ((sParent==tParent) && customTree.hasChildren(tId) == “”) this will not work!

Any idea plz help me

Support team please respond !

You need to use ‘complex’ dnd behaviour
But you need to redefine some things are described in this topic:
viewtopic.php?f=3&t=30937
And the do the next:

skipMoving = false; tree.attachEvent("onDragIn",function(sId,tId){ return tree.getParentId(sId) == tree.getParentId(tId) }) tree.attachEvent("onDrag", function(sId,tId,bId){ if( !skipMoving && tId != this.getParentId(sId)){ skipMoving = true; tree.moveItem(sId,'item_sibling_next',tId); return false; } skipMoving = false; return true });