Extjs4 In TreeGrid How to restricting leaf drag/drop within its parent node only

577 Views Asked by At

I need the tree to behave in such a way that when a user drags a leaf and tries to order it, the leaf can be ordered only within its parent. Can any one help me out in this...

eg:

fruits and vegetables(Root)
------\Fruits(Parent1)
---------\Orange (Leaf1.1)
---------\Apple (Leaf1.2)
---------\Dragon Fruit (Leaf1.3)
------\Veggie(Parent2)
---------\Potato (Leaf1)
---------\Beetroot (Leaf2)
---------\Yam (Leaf3)

The ordering is allowed only between the fruits or vegetables. Leaf's 1.1,1.2,1.3 can be sorted inside parent 1 only. Thanks.

3

There are 3 best solutions below

0
On

You have to by code only. In handler function of drag, check if the type is vegetable or fruit and parent's type is same. If both are not same, do nothing and call e.stopEvent().

--Sridhar

0
On

Please use treeviewdragdrop instead of gridviewdragdrop and then do something on the listener:

nodedragover( targetNode, position, dragData, e, eOpts )

Just like this:

view.on('nodedragover', function(node, position, dragData){
   var me = this, record = me.getRecord(node), srcNode = dragData.records[0];
    return srcNode.parentNode == record; 
});

I got it in my project.

0
On
treeGrid.setCanReparentNodes(false)