PDA

View Full Version : Getting Row Index from second Grid when data dropped in first Grid



grephin
16 Aug 2012, 12:37 AM
I'm new in extjs, all I want is to get the row index from second grid before the data is dragged when the data drop in the first grid.

this is the code :
var firstGrid = Ext.create('Ext.grid.Panel', {
multiSelect: false,
loadMask: true,
selModel: {
pruneRemoved: false
},
viewConfig: {
trackOver: false,
plugins: {
ptype: 'gridviewdragdrop',
dragGroup: 'firstGridDDGroup',
dropGroup: 'secondGridDDGroup'
},
listeners: {
drop: function(node, data, dropRec, dropPosition) {
var dd = Ext.getCmp('secondGrid');
var cindex=dd.getDragData(e).rowIndex;
alert(cindex); //it's not working
strStock.load();
strCart.load();
},
notifyDrop : function(source, e, data) {
var cindex = source.getDragData(e).rowIndex;
alert(cindex); // it's not working
}
}
},
store : strStock,
columns : columns,
stripeRows : true,
title : 'Stock Details',
margins : '3 2 2 2',
width : 694,
height : 500
});


can someone help me? I really appreciate your helps..
Thank You

redraid
16 Aug 2012, 3:26 AM
DD events is fired through the GridView. Add listeners to the GridView object:


Ext.create('Ext.data.Store', {
storeId:'simpsonsStore',
fields:['name'],
data: [["Lisa"], ["Bart"], ["Homer"], ["Marge"]],
proxy: {
type: 'memory',
reader: 'array'
}
});

Ext.create('Ext.data.Store', {
storeId:'simpsonsStore2',
fields:['name'],
data: [],
proxy: {
type: 'memory',
reader: 'array'
}
});

var g1 = Ext.create('Ext.grid.Panel', {
store: 'simpsonsStore',
columns: [
{header: 'Name', dataIndex: 'name', flex: true}
],
viewConfig: {
plugins: {
ptype: 'gridviewdragdrop',
dragText: 'Drag and drop to reorganize'
}
},
height: 200,
width: 400,
renderTo: Ext.getBody()
});

var g2 = Ext.create('Ext.grid.Panel', {
store: 'simpsonsStore2',
columns: [
{header: 'Name', dataIndex: 'name', flex: true}
],
viewConfig: {
plugins: {
ptype: 'gridviewdragdrop',
dragText: 'Drag and drop to reorganize'
},
listeners: {
beforedrop: function (node, data, dropRec, dropPosition) {
var record = data.records[0],
index = g1.getView().indexOf(record);

alert(index);
}
}
},
height: 200,
width: 400,
renderTo: Ext.getBody()
});