PDA

View Full Version : drag'n drop in grid groupingview



seltzlab
24 Apr 2010, 8:29 AM
Hi all,
I'm trying to implement a drag'n drop to allow moving a row from a group to another of the same grid.
Here's the code I'm writing:



new Ext.grid.EditorGridPanel({
id: 'mygrid-id',
autoHeight: true,
store: mygroupingstore,
colModel: mycolmodel,
selModel: new Ext.grid.RowSelectionModel({singleSelect: true}),
clicksToEdit: 2,
ddGroup: "mygridDD",
enableDragDrop: true,
view: new Ext.grid.GroupingView({
forceFit: true,
}),
listeners: {
render: function(grid){
grid.dropZone = new Ext.dd.DropZone(grid.getView().mainBody, {
containerScroll: true,
ddGroup: "mygridDD",
onNodeEnter : function(target, dd, e, data) {
Ext.fly(target).setStyle({
'border-bottom': '2px solid #000'
});
},
onNodeOver: function(target, dd, e, data) {
return Ext.dd.DropZone.prototype.dropAllowed;
},
onNodeOut: function(target, dd, e, data) {
Ext.fly(target).setStyle({
'border-bottom': '1px solid #e9e9e9'
});
},
onNodeDrop: function(target, dd, e, data) {
var r = data.selections[0];
return true;
},
onContainerDrop: function(source, e, data) {
},
getTargetFromEvent: function(e) {
return e.getTarget(grid.getView().rowSelector);
},
});
}
}
})
So, I'm a bit confused.
I'd like to know how I can retrieve the current grid group when dropping the row, on the "onNodeDrop" event.

Thanks for any help,
Antonio

Nesta
25 Apr 2010, 12:09 AM
record.store.groupField contains the current groupfield (dataindex)

therefor, this snippet will give you the value of groufield for a record
record.data[record.store.groupField]