PDA

View Full Version : DnD from Tree to Grid.Bug?



adp-gmt
21 Sep 2012, 2:06 AM
Hello,
I am using EXTJS 4.1.1
Why the behavior differs depending on whether I DnD from Tree1 to Tree2 and from Tree1 to Grid1?
In the following example, when I DnD the node "Drag me,please.Id assigned by adp-gmt" from Tree1 to Tree2 and from Tree1 to Grid1 ,it's works fine.When I DnD the node "Drag me,please.Id assigned by adp-gmt" from Tree1 to Tree2 and from Tree1 to Grid1 again, the DnD from Tree1 to Grid1 throws the following error ("'internalId' is null or not an object") because I try to insert another record with the same Id.
Should I override Ext.grid.ViewDropZone ?


Ext.require(['*']);

Ext.onReady(function(){
var store = Ext.create('Ext.data.TreeStore', {
root: {
text: 'tree1',
id: 'src',
expanded: true,
children: [
{ text: "Drag me,please.Id not assigned by adp-gmt", leaf: true },
{ text: "Folder", expanded: true, children: [
{ id: 'new-id',text: "Drag me,please.Id assigned by adp-gmt", leaf: true }
] }
]
}
});


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




var store2 = Ext.create('Ext.data.TreeStore', {
root: {
text: 'tree2',
id: 'src',
expanded: true,
children: [
{ text: "One Piece", leaf: true },
{ text: "Folder", expanded: true, children: [
{ text: "Casshern", leaf: true }
] }
]
}
});


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

var grid1 = new Ext.grid.Panel({
id: 'grid1',
width: 300,
height: 150,
store : new Ext.data.Store({
id:'store1',
fields: ['id','text'],
data : [{id : 'node1', text : 'node1'},{id : 'node2', text : 'node2'}]
}),
columns : [ {text: 'id', dataIndex: 'id'},{text: 'text', dataIndex: 'text'}],
viewConfig: {
plugins:{
ptype: 'gridviewdragdrop',
ddGroup : 'ddGroup'
}
},
renderTo: document.body
});
});

mitchellsimoens
24 Sep 2012, 5:44 AM
With your example, I dragged the first leaf node from tree 1 to tree 2. It appeared in tree 2 and stayed in tree 1. I then dragged the same leaf node from tree 1 to grid 1 and it appeared in grid 1 and stayed in tree 1. I didn't get any errors using 4.1.1

adp-gmt
24 Sep 2012, 6:19 AM
You have to drag the second leaf node from tree 1 to grid 1.The second time,you drag it,you get the following error: 'internalId' is null or not an object

I had to override Ext.grid.ViewDropZone.handleNodeDrop to resolve the problem.