PDA

View Full Version : Getting component for DropTarget



Albinoswordfish
30 Dec 2010, 1:24 PM
var dd = new Ext.dd.DropTarget(this.el.dom, {
ddGroup:'tl'
,
notifyDrop:function(dd, e, data) {
var myBoxComp = Ext.getCmp("timelinepanel");
return true;
}
});

Above I have this code that defines a DropTarget which is being created in a BoxComponent, the problem I have is that the only way to get the component that is initiating the DropTarget is using the Ext.getCmp() method and using the id of the component. However this method would not scale for multiple instances of the BoxComponent. Is there a better way of getting the component which initiated the DropTarget?

skirtle
30 Dec 2010, 3:43 PM
Am I right in thinking that this is the BoxComponent called 'timelinepanel'? If it is, you could try either:


var me = this;

var dd = new Ext.dd.DropTarget(this.el.dom, {
ddGroup: 'tl',
notifyDrop: function(dd, e, data) {
// me is 'timelinepanel'
alert(me);
return true;
}
});or:


var dd = new Ext.dd.DropTarget(this.el.dom, {
ddGroup: 'tl',
notifyDrop: function(dd, e, data) {
// this is 'timelinepanel'
alert(this);
return true;
}.createDelegate(this)
});