View Full Version : How to find a DropTargets' store?

7 Apr 2010, 6:11 AM
Hi all
I desperately try to have DD between different GridPanels. A JsonStore first gets all the data needed. it iterates over the data and creates several gridPanels and populates a Window with them.

the following function is used to get the Panels:

function createGridPanel(orgLocationDesc, records){
var recordType = Ext.data.Record.create([
{name: 'orgLocationDesc'},
{name: 'orgLocationId'},
{name: 'patientId'},
{name: 'patientName'},
{name: 'remarks'}
var orgLocationId = records[0].get('orgLocationId');
var tmpStore = new Ext.data.Store({
id: 'gridStore_'+orgLocationId,
reader: new Ext.data.ArrayReader(
{ idIndex: 1 },
var gridPanel = new Ext.grid.GridPanel({
id: 'gridPanel_'+orgLocationId,
title: orgLocationDesc,
store: tmpStore,
[{header: 'Patient-Name', width: 300, dataIndex: 'patientName'},
{header: 'Bemerkungen', width: 300, dataIndex: 'remarks'}],
width: 620,
stripeRows: true,
autoHeight: true,
frame: false,
border: true,
enableDragDrop: true,
ddGroup: 'gridDD'
gridPanel.on('render', function(){
gridPanel.ddTarget = new Ext.dd.DropTarget(gridPanel.container, {
ddGroup: 'gridDD',
id: 'ddTarget_' +orgLocationId,
notifyDrop: function(dd, e, data){
var dstStore = gridPanel.getStore();
var srcStore = dd.grid.store;
return gridPanel;
The panels are all created as desired, having correct data in it. Only DD doesn't work. Plan is to remove the dragged record from the srcStore (which is correctly found) and the add the record to the dstStore. strange is that i am not able to get a reference to the gridPanels's store.

if this method called multiple times dstStore always holds a reference to the gridStore which was created at last.

any ideas are HIGHLY appreciated!!!

7 Apr 2010, 6:46 AM
See the following grid to grid drag and drop example:


7 Apr 2010, 7:02 AM
thanks, i've tried to stick on that example but the difference in the example is that there are only 2 grids. in my case i have n grids dynamically created. therefore i have no reference such as "secondGrid.store" as in the example. :((

deleting from the source grid's store works but i have no clue on how to add the record to the destination grid...

am i missing something?

7 Apr 2010, 7:06 AM
I don't get it. When you create the drop target, you have a reference to the destination grid.

7 Apr 2010, 7:06 AM
Also, have a good look at the drop event.

7 Apr 2010, 7:10 AM
thanks, i'll check the drop event. where is it? in the DropTarget?

7 Apr 2010, 7:12 AM
e == event.

notifyDrop: function(dd, e, data){
var dstStore = gridPanel.getStore();
var srcStore = dd.grid.store;