PDA

View Full Version : Node disappear after Drag&Drop



adp-gmt
20 Sep 2012, 8:21 AM
Hello,
I'm using EXTJS 4.1.1
In the following example,I'm able to drag&&drop a node from tree1 to tree2 but how to prevent the node to disappear from the tree1 ?


Ext.require(['*']);


Ext.onReady(function(){
var store = Ext.create('Ext.data.TreeStore', {
root: {
text: 'Tree1',
id: 'src',
expanded: true,
children: [
{ text: "store1-node-1", leaf: true },
{ text: "store1-node-2", expanded: true, children: [
{ text: "store1-node-2-1", leaf: true }
] }
]
},
});


var tree = Ext.create('Ext.tree.Panel', {
id: 'tree1',
store: store,
width: 250,
height: 300,
viewConfig: {
plugins: {
ptype: 'treeviewdragdrop',
enableDrop : false,
allowContainerDrops : false
}
},
renderTo: document.body
});


var store2 = Ext.create('Ext.data.TreeStore', {
root: {
text: 'Tree2',
id: 'src',
expanded: true,
children: [
{ text: "store2-node-1", leaf: true },
{ text: "store2-node-2", expanded: true, children: [
{ text: "store2-node-2-1", leaf: true }
] }
]
},
});


var tree2 = Ext.create('Ext.tree.Panel', {
id: 'tree2',
width: 250,
height: 300,
store: store2,
viewConfig: {
plugins: {
ptype: 'treeviewdragdrop'
}
},
renderTo: document.body
});
});

adp-gmt
20 Sep 2012, 11:29 PM
I found the solution.Add "copy: true" in the tree1 viewConfig

delusion
1 Feb 2013, 8:09 AM
This works to force the mode into copy. however it also changes the 'data' that is passed to the drop event. Instead of getting the entire node, the data is now just the node.data object. Which is fine, except I want to add things to the node.data object based on the nodes siblings and I haven't been able to do that yet. Anyone else run into this?