Search code examples
extjswindowhandler

Custom function on closeAction in Ext.Window


I have aded extjs window as follows,

var popupWindow = me.popupWindow = new Ext.window.Window({
                    autoHeight: true,
                    itemId: 'popup',
                    cls: 'premier-window',
                    width: 550,
                    height: 280,
                    layout: {
                        pack: 'center'
                    },
                    shadow: false,
                    modal: true,
                    frame: false,
                    resizable: false,
                    isPremierPanel: true,
                    usePremierCloseButton: true,
                    closeAction: 'hide',
                    dockedItems: [
                        {
                            dock: 'bottom',
                            xtype: 'toolbar',
                            itemId: 'button_toolbar',
                            style: 'background:#F5F3F4;broder:0',
                            items: [
                            {
                                dock: 'bottom',
                                xtype: 'button',
                                itemId: 'btnOk',
                                style: 'margin-left:230px;background:#D3D3D3;',
                                text: 'OK',
                                width: 70,

                              handler: me.okClicked,
                                scope: me
                            } 
                            ]
                        }
                    ],
                    style: 'background-color:#F5F3F4; font-size:11px; padding-bottom:10px; margin-left:10px;',
                    html: '<div style="padding-left: 7px;padding-right: 7px;padding-top: 7px;font-size:12px;">'  
                });
                popupWindow.show();
                popupWindow.setTitle('Restricted Access');

How to customize closeAction functionality of an extjs window?

I want to do something other than destroying or hiding the window when clicked on default close button of a window.


Solution

  • listeners:{
        beforeclose:function() {
            if(I_DONT_WANT_TO_CLOSE) {
                doSomethingAndDontCloseTheWindow()
                return false;
            }
        }
        close:function() {
            doSomethingAfterWindowHasBeenClosed();
        }
    }