View Full Version : Question about constructors.

3 Sep 2010, 8:39 AM
I have a simple Ext.Window and I am testing it in FF 3.6.8

var myWin = new Ext.Window({
id : 'myWin',
closeAction : 'close',
autoDestroy : true,
layout : 'fit',
plain : false,
modal : true,
title : 'Test',
width : 675,
height : 400,
border : false,
items : [grid]

myWin.addListener('destroy', function(){console.info('myWin Destroyed')})


If I call the constructor and show the window and then manually resize it and then close the window by clicking on the "X", The window closes and the destroy method fires.

Then if I call the constructor again, the window opens to the re-sized size and not the width and height in the constructor.


Thanks for your reply.

3 Sep 2010, 9:00 AM
Steve, you're doing something wrong somewhere. Ext jS does not cache the size of the window.

3 Sep 2010, 9:04 AM
I stand corrected! This is a bug with Ext JS: http://tdg-i.com/img/screencasts/2010-09-03_1303.swf

3 Sep 2010, 9:04 AM
Heh, lesson to learn : stop using static ids!

3 Sep 2010, 10:47 AM
Heh, lesson to learn : stop using static ids!

If I don't use a static ID, how am I supposed to reference specific forms/fields/grids/etc. to do data binding?

Or do you simply mean that one should not use static IDs unless you actually need to look up the component with Ext.Cmp()?

3 Sep 2010, 10:56 AM
You can implement the Container Model utility methods to gain access or use tools like the 'ref' property. Either way, static ids are not a good choice for app development with Ext JS.

I am actually in the middle the edit phase of my next screencast "The dangers of Ext.getCmp", which was a talk I did at the Sencha office on 8/17.

I also discuss this in my book in chapters 16 and 17. You can look at the application code at http://app.extjsinaction.com and you'll see that not a single static id is used. Not one.

3 Sep 2010, 12:47 PM

6 Sep 2010, 3:11 AM
The problem is that ids are used as stateIds by the state manager.

I disable all state management by default:

Ext.Component.prototype.stateful = false;
and only configure stateful:true for components that I actually want to keep state for.