ExtJS: check window state (minimized, maximized, etc.)

ExtJS provides several configurations as to whether the Window is configured as maximized , minimizable , etc. It also provides the functions maximize and minimize a window.

It is impossible to find which correct way to get the existing state of the window. I need functions like the ones below:

var myWin = Ext.create('Ext.window.Window', { ... }); ... myWin.isMinimized(); // is current window minimized? myWin.isMaximized(); // is current window maximized? 

Can the current state of the window be retrieved from the window instance?

+4
source share
3 answers

For maximize() there is a boolean property maximized , which you can select from an object:

 if (myWin.maximized) { ... } 

However, to minimize() ExtJS does not provide any functions and expects a separate implementation. Therefore, no minimized property is supported in this field.

+3
source

@ The answer to VisioN is already complete, but I want to show you a snippet using toggleCollapse() to hide the window:

 Ext.create('Ext.Window',{ height: 100, width: 100, minimizable: true, listeners: { minimize: function(){ var win = this; win.toggleCollapse(); if (!win.getCollapsed()) { win.center(); } else { win.alignTo(document.body, 'bl-bl'); } } } }).show(); 
+1
source

One solution for anyone looking, instead of using minimizable config, use tools . Here is a complete example.

 var isMinimized = false; //if you want to check for minimized elsewhere.. var winWidth; //to restore to actual width. Ext.create('Ext.window.Window', { title: 'Hello', closable : false, width : 300, height : 400, tools: [ { type: 'restore', hidden : true, handler: function( evt,toolEl,owner,tool ) { var window = owner.up( 'window' ); window.expand('',false); window.setWidth(winWidth); window.center(); isMinimized = false; this.hide(); this.nextSibling().show(); } },{ type: 'minimize', handler: function( evt,toolEl,owner,tool ){ var window = owner.up( 'window' ); window.collapse(); winWidth = window.getWidth(); window.setWidth( 150 ); window.alignTo( Ext.getBody(), 'bl-bl'); this.hide(); this.previousSibling().show(); isMinimized = true; } } ] }).show(); 
+1
source

All Articles