PDA

View Full Version : window.maximize not working in 4.0.7



ritteh
30 Nov 2011, 5:54 PM
I am trying to call the maximize method of a window, however it is not working. I have stepped through the code and found the following line to be the culprit:

me.tools.maximize.hide()

The maximize property does not exist on me.tools. Can anyone tell me why this is or suggest a work-around?

mitchellsimoens
1 Dec 2011, 6:49 AM
This is working properly in 4.0.7 for me:


var win = Ext.create('Ext.window.Window', {
width : 400,
height : 400,
title : 'Test'
});

win.show();

setTimeout(function() {
win.maximize();
}, 1000);

ritteh
1 Dec 2011, 4:41 PM
This fails on 4.0.7 but works on 4.0.2.


<div id="viewer"></div>
<script>
Ext.create("Ext.toolbar.Toolbar", {
renderTo: 'viewer',
items: [{
xtype: 'button', text: 'Create Window', handler: function(me, eOpts) {
var win = Ext.create('Ext.window.Window', {maximizable: true, width: 500, height: 300});
win.setTitle("Window");
win.show();
setTimeout(function() {
win.maximize();
}, 1000);
}
}]
});
</script>

Click the Create window button. It won't maximize. Try clicking the maximize button it still does not maximize.

I also tried making win a global variable, thinking it was just losing reference, but same results.

Error in Firebug is: me.tools.maximize is undefined, me.tools.maximize.hide(); ext-all-debug.js (line 65701)

tudock
30 Jan 2012, 5:55 AM
I had the same problem!
The difference between the working and the not working example is the
win.setTitle('Changed Title');

Because in 4.0.7 the tools are getting cloned in the initTools()-Method the reference is getting lost, when the updateHeader()-Method is being called. Afterwards the tools-object is empty and you get the Error.
My Quick and dirty solution is, to revert the initTools()-Method to the 4.0.2-Version:

/**
* @private
* Tools are a Panel-specific capabilty.
* Panel uses initTools. Subclasses may contribute tools by implementing addTools.
*/
initTools: function() {
var me = this;

/**
* maximize bug, do not clone object
*/
me.tools = me.tools || [];

// Add a collapse tool unless configured to not show a collapse tool
// or to not even show a header.
if (me.collapsible && !(me.hideCollapseTool || me.header === false)) {
me.collapseDirection = me.collapseDirection || me.headerPosition || 'top';
me.collapseTool = me.expandTool = me.createComponent({
xtype: 'tool',
type: 'collapse-' + me.collapseDirection,
expandType: me.getOppositeDirection(me.collapseDirection),
handler: me.toggleCollapse,
scope: me
});

// Prepend collapse tool is configured to do so.
if (me.collapseFirst) {
me.tools.unshift(me.collapseTool);
}
}

// Add subclass-specific tools.
me.addTools();

// Make Panel closable.
if (me.closable) {
me.addClsWithUI('closable');
me.addTool({
type: 'close',
handler: Ext.Function.bind(me.close, this, [])
});
}

// Append collapse tool if needed.
if (me.collapseTool && !me.collapseFirst) {
me.tools.push(me.collapseTool);
}
},

geek0r
13 Jul 2012, 1:33 AM
This is still not working in 4.1.1!!

geek0r
13 Jul 2012, 3:19 AM
It seems that it is really important to call setTitle only when the window is "kind of visible". I have a dynamic function that sets the title based on the "master record" of the first form inside the window. When calling setTitle in the show-listener maximize is working. If the window is still hidden then calling setTitle maximize will fail.