PDA

View Full Version : Drag and Drop between 3 grid : wrong notifyDrop called.



slemiere
26 Nov 2009, 2:50 AM
Hi,

I am trying to use drag and drop in my application and I need to have two differents grid dragging to the same grid, but with different notifyDrop behaviour. My problem is whatever grid i drag from, it is always the same notifyDrop called even when I set two different ddGroup in grids. To show it in action I used this example (http://www.extjs.com/deploy/dev/examples/dd/dnd_grid_to_grid.html) and hack it with firebug using the following code.



var fields = [
{name: 'name', mapping : 'name'},
{name: 'column1', mapping : 'column1'},
{name: 'column2', mapping : 'column2'}
];
var cols = [
{ id : 'name', header: "Record Name", width: 160, sortable: true, dataIndex: 'name'},
{header: "column1", width: 50, sortable: true, dataIndex: 'column1'},
{header: "column2", width: 50, sortable: true, dataIndex: 'column2'}
];

//creating the Third grid
var tGridStore = new Ext.data.JsonStore({
fields : fields,
root : 'records'
});
tGrid = new Ext.grid.GridPanel({
//different ddGroup
ddGroup: 'tGridDDGroup',
store: tGridStore,
columns: cols,
enableDragDrop: true,
stripeRows: true,
autoExpandColumn: 'name',
title: '3 Grid'
});
//ext-comp-1003 is the panel
Ext.getCmp('ext-comp-1003').add(tGrid);
Ext.getCmp('ext-comp-1003').doLayout();
//drop to tgrid from grid 1 - OK
var secondGridDropTargetEl = tGrid.getView().scroller.dom;
var secondGridDropTarget = new Ext.dd.DropTarget(secondGridDropTargetEl, {
ddGroup : 'secondGridDDGroup',
notifyDrop : function(ddSource, e, data){
var records = ddSource.dragData.selections;
Ext.each(records, ddSource.grid.store.remove, ddSource.grid.store);
tGrid.store.add(records);
tGrid.store.sort('name', 'ASC');
return true
}
});
firstGrid = Ext.getCmp('ext-comp-1003').items.items[0];
//drop to grid 1 from tgrid - Problem here
var firstGridDropTargetEl = firstGrid.getView().scroller.dom;
var firstGridDropTarget = new Ext.dd.DropTarget(firstGridDropTargetEl, {
//using the proper ddGroup
ddGroup: 'tGridDDGroup',
//this seems to never be called, notifyDrop of the second grid called instead
notifyDrop: function(ddSource, e, data){
console.log('from grid 3');
return true;
}
});


To reproduce my problem just drag a row from grid 1 to grid 3 and then drag from grid 3 to grid 1. You should see the record disappears from grid 3 and appears in grid 1 although the notifyDrop for grid 3 is just logging 'from grid 3' to the console.

Do I didn't understand the correct usage of ddGroup or Am I missing something more obvious ?

Thanks for help,

Sylvain

slemiere
30 Nov 2009, 1:31 AM
Hello,

No response so far, is anything not clear in my post ? I can clarify if it's needed...

Thanks in advance for help !

slemiere
7 Dec 2009, 8:50 AM
Hello every one !

I just bump one more time my thread. Is there really no one who has any response to my question ? I am not asking for a solution, I just want to know If I made a mistake in my code or if it may be a bug of extjs...

Any help would be very much appreciated !

Sylvain

7 Dec 2009, 9:08 AM
can you post something that can easily reproduce this issue?