PDA

View Full Version : Change 'draggable' for a panel after its rendered



zz9pa
2 Jul 2013, 5:42 AM
I need to be able to change the "draggable" setting for a panel when I reset its parent.
Is this possible ?

I can do it at creation time using (in my case) :

newitem.draggable =
{
constrainedTo: mainPanel,
}

for one of my needs and :

newitem.draggable =
{
moveOnDrag: false
}

for the other - depending on where i re-add it - I need to toggle between these ...

(just setting .draggable isnt doing it..)


Thanks in advance

slemmon
3 Jul 2013, 4:27 PM
The draggable config accepts a config object to be applied to the instance of Ext.panel.DD so you can do something like this:



Ext.define('MyPanel', {
extend: 'Ext.panel.Panel',
myDraggable: true,
initComponent: function () {
var me = this;

me.draggable = {
b4Drag: function (e) {
//this.setDragElPos(e.getPageX(), e.getPageY());
if (me.myDraggable === true) {
this.setDragElPos(e.getPageX(), e.getPageY());
} else {
return false;
}
}
}

me.callParent(arguments);
}
});


Ext.create('MyPanel', {
title: 'Hello',
width: 200,
html: '<p>World!</p>',
renderTo: Ext.getBody()
});