10

I have a Window. I'm having some issues with the default close button which is on the top-right hand corner of the window. Therefore i was thinking to disable that close button and add a close button so that when the user clicks will disable/remove the window. What is the code to remove/close the Window.

The Window definition is as follows;

Ext.define('MyApp.view.MyWin', {
    extend: 'Ext.window.Window',
    alias: 'widget.mywin',
......
Illep
  • 16,375
  • 46
  • 171
  • 302
  • You want to remove the close button just to add another button that looks and does exacly the same? – AndreKR Dec 13 '12 at 22:23
  • I don't think you can do that (but if it's possible please do share). I want to add a normal button, then name it close, and upon clicking it to close the Window. – Illep Dec 13 '12 at 22:39
  • You mean like this? http://jsfiddle.net/X43Fz/ – AndreKR Dec 13 '12 at 22:47
  • SO in my case is it mywin.close(); ? – Illep Dec 13 '12 at 23:17
  • If `mywin` is the variable holding an instance of your window, yes. The code you showed does not open any window, so we can't tell you how to close that window in particular. See my answer for a window that closes itself. – AndreKR Dec 13 '12 at 23:45

1 Answers1

27

It's just close().

Working example:

new Ext.window.Window({
    title: 'A window',
    closable: false, // hides the normal close button
    width: 300,
    height: 300,
    bbar: [
        {
            text: 'Close',
            handler: function () { this.up('window').close(); }
        }
    ],
    autoShow: true
});
AndreKR
  • 32,613
  • 18
  • 106
  • 168