PDA

View Full Version : Drag and Drop between GridPanel and TreePanel



mkaw
20 Jun 2012, 1:33 AM
I have TreePanel and GridPanel. I have to drag elements from grid to tree. My code:


items: [
{
xtype: 'treepanel',
title: 'My Tree Panel',
store: 'TreeStore',
flex: 1,
viewConfig: {
plugins: [
Ext.create('Ext.tree.plugin.TreeViewDragDrop', {
ptype: 'treeviewdragdrop',
appendOnly: true,
ddGroup: 'struct'
})
]
}
},
{
xtype: 'gridpanel',
title: 'My Grid Panel',
flex: 1,
store: 'GridStore',
columns: [
{
xtype: 'gridcolumn',
dataIndex: 'name',
text: 'Name'
},
{
xtype: 'numbercolumn',
dataIndex: 'id',
text: 'Id'
}
],
viewConfig: {
plugins: [
Ext.create('Ext.grid.plugin.DragDrop', {
ptype: 'gridviewdragdrop',
ddGroup: 'struct'
})
]
}
}
]

When i drop on tree i have this erros:


ext-all-dev.js:55892Uncaught TypeError: Object [object Object] has no method 'updateInfo'ext-all-dev.js:56897Uncaught TypeError: Object [object Object] has no method 'eachChild'
Models in my stores are different. What i have to do to make this work ?

@edit
Solution was simple. On beforedrop in TreeViewDragDrop plugin i use Ext.data.NodeInterface.decorate().


onTreedragdroppluginBeforeDrop: function(node, data, overModel, dropPosition, dropFunction, options) {
for(int x=0;x<data.record.length;x++){
Ext.data.NodeInterface.decorate(data.records[x]);
}
}

mkaw
21 Jun 2012, 11:06 PM
When I append node like this, I have another error:

Uncaught TypeError: Object #<Object> has no method 'apply'

sudarshanj
19 Apr 2013, 3:07 AM
I got error like this 'Uncaught TypeError: Cannot read property 'length' of undefined '