PDA

View Full Version : More TreeViewDragdrop Functionality



RiaanSA
9 May 2012, 12:31 AM
What I have is a drag drop between 2 tree views.



var tree = new Ext.tree.TreePanel({
store: Availablestore,
enableDrag:true,
rootVisible: true,
region:'west',
title:'Available Dataset',
layout:'fit',
width:200,
collapsible:true,
autoScroll:true,
viewConfig: {
plugins: {
ptype: 'treeviewdragdrop',
appendOnly: true
}
}
});

// create drop target in center
var target = new Ext.tree.TreePanel({
store: Selectedstore,
enableDrag:true,
rootVisible: true,
region:'center',
title:'Selected Dataset',
layout:'fit',
width:200,
collapsible:false,
autoScroll:true,
viewConfig: {
plugins: {
ptype: 'treeviewdragdrop',
appendOnly: true
}
}
}); // eo target
// }}}


Now I want to force people to only drop on the root node. This will ensure that the items does not get messy with dropping items and creating endless indentations on the source and target tree views.

Please advice.

chesstrix
5 Jul 2012, 10:30 PM
Might be a little late but....



viewConfig : {
plugins : [{
ptype : 'treeviewdragdrop',
appendOnly : true,
ddGroup : 'myDDgroup'
}],
listeners : {
beforedrop: function(n, d, o, p, h, e){
// if you don't want to allow a drop event for some reason...
return false;
}
}
}


Hope it helps.

RiaanSA
6 Jul 2012, 2:41 AM
Hi,

Yes I have managed to solve the problem using the technique you mention there.

But I am trying to take it to the next level.

Check this link. (http://www.sencha.com/forum/showthread.php?205841-How-to-set-default-drop-in-TreePanel-to-always-be-quot-root-quot-node)

Thanks for the reply.

Greendrake
14 Mar 2013, 12:31 AM
I am trying to take it to the next level.
I wish Ext JS had the ability to specify custom DragZone and DropZone classes in TreeViewDragDrop plugin. Currently Ext.tree.ViewDragZone and Ext.tree.ViewDragZone are hard-coded in there.
For example, instead of


me.dragZone = new Ext.tree.ViewDragZone({
......
});

there could be:


me.dragZone = Ext.create(me.dragZoneClass, {
....
});

In you use your own d'n'd classes you can do whatever you want, effectively "taking it to the next level".
I'm actually doing that at the expense of maintaining my own local Ext JS branch.