1
votes

I have an extjs panel. I need to induce a drag and resizing property for this panel.

This is the code for creating the panel:

var childPanel = new Ext.Panel({
                    draggable: true,
                    layout: 'fit',

 ................
});

I have achieved drag and resizing properties using the code:

Ext.override(Ext.Panel, {
                    // private
                    initEvents: function () {

                        if (this.draggable) {
                            this.initDraggable();
                        }
                        this.resizer = new Ext.Resizable(this.el, {
                            animate: true,
                            duration: '.6',
                            easing: 'backIn',
                            handles: 'all',
                            pinned: false,
                            transparent: true
                        });
                        this.resizer.on("resize", this.onResizer, this);
                    },
                    onResizer: function (oResizable, iWidth, iHeight, e) {
                        this.setHeight(iHeight);
                        this.setWidth(iWidth);
                    }
                });

As you can see I am overriding the property. Therefore all the panels that I create have these properties. I don't want it like that.

I know that Ext.extend is the method to use but each time I am getting some errors. What I need is an extended panel with the above code.

Can anybody help me to achieve this?

1
I agree with Benoit, please post the extend code you're having problems with - dougajmcdonald

1 Answers

1
votes

Have you tired extending? what were the errors? Your should remmeber to call the superclass constructor from the extended methods.

MYDRAGRESIZEPANEL = Ext.extend(Ext.Panel,{
    // private
                initEvents: function () {
                    **MYDRAGRESIZEPANEL.superclass.constructor.call(this);**
                    if (this.draggable) {
                        this.initDraggable();
                    }
                    this.resizer = new Ext.Resizable(this.el, {
                        animate: true,
                        duration: '.6',
                        easing: 'backIn',
                        handles: 'all',
                        pinned: false,
                        transparent: true
                    });
                    this.resizer.on("resize", this.onResizer, this);
                },
                onResizer: function (oResizable, iWidth, iHeight, e) {
                    this.setHeight(iHeight);
                    this.setWidth(iWidth);
                }
});