PDA

View Full Version : How can I change an attribute to a window?



StevenInc
9 Sep 2009, 3:28 AM
I am using an Ext.Window as a main layout to my application and I am setting the width and height dynamically, based on the browser's innerWidth and innerHeight. With a max Ext.Window width of 1600px. I have notice that will the Ext.Window is set to the innerWidth of the browser (FF 3.5) The Right side scroll bar covers up the Ext.Window Content. So I set the Ext. Window width to 22px less to compensate.

If the monitor is larger than 1600px, I want center the Ext. Window. and if it is less, I need to anchor the Window to the left. I have been using the x:0 parameter to do this but I have 2 Ext.Windows in an if statement to accomplish this.


if(windowSetToInnerWidth){//align to left

var myWin = new Ext.Window({
width: applicationWidth,
height: applicationHeight,
x:0,
y:0,
frame: false,
closable: false,
layout: 'border',
renderTo: Ext.getBody(),
items: [ myItems ]
});//myWin

}
else{//center align

var myWin = new Ext.Window({
width: applicationWidth,
height: applicationHeight,
// x:0, I comment this line out to center the window in the browser.
y:0,
frame: false,
closable: false,
layout: 'border',
renderTo: Ext.getBody(),
items: [ myItems ]
});//myWin

};



Is there a better way?

Thanks

9 Sep 2009, 3:37 AM
the better way would be to try to reduce the lines of code significantly:



var myWin = new Ext.Window({
width : applicationWidth,
height : applicationHeight,
x : (windowSetToInnerWidth) ? 0 : null,
y : 0,
frame : false,
closable : false,
layout : 'border', // < why set to fit if only one item!?
//renderTo : Ext.getBody(), < not neeeded
items : [ myItems ]
});

StevenInc
9 Sep 2009, 5:04 AM
Jesus, Thanks for the reply.
I am having trouble with the null.
x : (windowSetToInnerWidth) ? 0 : null,

When
windowSetToInnerWidth is false, I get a white screen without any js errors.

Thanks.

* I am using regions, I omitted them to simplify the code.

ps - your book ROCKS! - Thank you, it is a savior!

9 Sep 2009, 5:25 AM
btw, setting frame:false on the window will prevent it from doing what it needs to do :)

Try this instead.


var myWin = new Ext.Window({
width : applicationWidth,
height : applicationHeight,
y : 0,
//frame : false,
closable : false,
layout : 'border', // < why set to fit if only one item!?
//renderTo : Ext.getBody(), < not neeeded
items : [ myItems ]
});

if (windowSetToInnerWidth) {
myWin.x = 0;
};

StevenInc
9 Sep 2009, 5:34 AM
Thank you. That solves my issue.
I appreciate it.