PDA

View Full Version : draggable panel is not moving with mouse.



AbishaShajin
11 Jul 2013, 9:09 PM
Hi Friends,

I am new to extjs 4. Trying to make a drag and drop example. it is working fine. but the dragging panel is not moving with mouse until it dropped in another panel. Here i have used b4sSartDrag to get initial position of the panel. It is also throwing an error "Uncaught TypeError: Cannot read property 'el' of undefined". When I included b4sSartDrag, OnDrag is also not working. I could not understand, What did go wrong here.


dragOver = {
b4StartDrag : function(x,y){
var orgpel = this.proxy.getEl();
this.orgx = orgpel.getLeft(true);
this.orgy = orgpel.getTop(true);

},
insertProxy: false,
onDrag :function(e){
var pel = this.proxy.getEl();
this.xp = pel.getLeft(true);
this.yp = pel.getTop(true);
var s = this.panel.getEl().shadow;
if (s) {
s.realign(this.xp, this.yp, pel.getWidth(),pel.getHeight());
}
},
endDrag : function(e) {
if (this.invalidDrop != true){
this.panel.setPosition(this.xp, this.yp);
}else{
this.panel.setPosition(this.orgx, this.orgy);
}
delete this.invalidDrop;
},
onDragDrop : function(e,s){
var cmp = Ext.getCmp(s);
cmp.add(this.panel);
cmp.doLayout();
return (true);
},
onInvalidDrop : function() {
this.invalidDrop = true;
}
};

var panel2 = new Ext.Panel({
renderTo : 'panel2-id',
autoHeight : true,
bodyStyle : 'padding : 5px',
defaults : { xtype:'panel',border : true,autoHeight : true},
items :[{id : 'panel-1',items:[{style : 'margin-bottom: 5px',draggable :dragOver,frame : true, height : 70, width:300,html : 'First Panel',title : 'Title 1'}]},
{id : 'panel-2',items:[{style : 'margin-bottom: 5px',draggable :dragOver,frame : true, height : 50, width:300,html : 'Second Panel', title : 'Title 2'}]}],
listeners:{
render : function(cmp, eOpts){
var chilitem = cmp.items ? cmp.items.items : [];
Ext.each(chilitem,function(item){
var itemId = item.getId();
var sourcePanelDropTarget = new Ext.dd.DropTarget(itemId,{
isTarget : false
});
})
}
}
});


Can you please anybody help to solve this problem?

AbishaShajin
12 Jul 2013, 3:19 AM
:( No reply