PDA

View Full Version : Drag/Drop - Want to drop onto Grid Group Header



bbxx
30 Oct 2009, 10:08 PM
I would like to do something when someone drags a record onto a group header in a grid I have.

I have added basic drop code onto my grid and when I drop something onto my grid, the rowIndex is not defined, which makes sense since I'm not dropping onto a record, but can I get the field that the group is grouped by or something?

Any ideas? Thanks



firstGridDropTargetEl = GroupsMainGrid.getView().scroller.dom;
firstGridDropTarget = new Ext.dd.DropTarget(firstGridDropTargetEl, {
ddGroup : 'firstGridDDGroup',
notifyDrop : function(ddSource, e, data){
var records = ddSource.dragData.selections;

alert(ddSource.getDragData(e).rowIndex );
/*
var records = ddSource.dragData.selections;
Ext.each(records, ddSource.grid.store.remove, ddSource.grid.store);
firstGrid.store.add(records);
firstGrid.store.sort('name', 'ASC');
*/
return true
}
});

Animal
31 Oct 2009, 12:37 AM
I agree that the GroupingView needs some more public methods to allow developers to easily link DOM events and DOM elements with internal class structure.

try



Ext.extend(Ext.grid.GroupingView, {
getGroupData : function(e){
var groupBody = e.getTarget('.x-grid-group', this.mainBody);
if(groupBody){
var hd = groupBody.child('.x-grid-group-hd');
if (hd) {
var groupValue = hd.id.substring(hd.id.lastIndexOf('-') + 1);
return {
groupField: this.getGroupField(),
value: groupValue
};
}
}
}
});


That'll tell you exactly what you are dropping on. You can set the Field in the dropped Records to force them to be dropped into that group.

bbxx
2 Nov 2009, 10:04 AM
I agree that the GroupingView needs some more public methods to allow developers to easily link DOM events and DOM elements with internal class structure.

try



Ext.extend(Ext.grid.GroupingView, {
getGroupData : function(e){
var groupBody = e.getTarget('.x-grid-group', this.mainBody);
if(groupBody){
var hd = groupBody.child('.x-grid-group-hd');
if (hd) {
var groupValue = hd.id.substring(hd.id.lastIndexOf('-') + 1);
return {
groupField: this.getGroupField(),
value: groupValue
};
}
}
}
});
That'll tell you exactly what you are dropping on. You can set the Field in the dropped Records to force them to be dropped into that group.

Thanks Animal!

Alex84
7 Dec 2009, 11:48 PM
@bbxx

can you post your code how you access the getGroupData method?

Thank You!

bbxx
8 Dec 2009, 12:13 AM
Sorry Alex, I haven't implemented the code I was going to use this for yet. I will post back when I have a chance to use it.

Alex84
8 Dec 2009, 12:16 AM
Ok thank you for your answer.

I get an error groupBody.child is not a function

josh803316
15 May 2010, 6:08 AM
@bbxx or Alex84, did either of you ever get this working? Do you have an example of how you implemented it?

I posted a link about this before I found your thread: http://www.extjs.com/forum/showthread.php?99226-Dropzone-for-grouping-grid-so-drops-can-go-into-groups