Results 1 to 5 of 5

Thread: How can I change an attribute to a window?

  1. #1
    Sencha User StevenInc's Avatar
    Join Date
    Jul 2009
    Location
    San Francisco
    Posts
    75

    Default How can I change an attribute to a window?

    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.
    Code:
    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
    Steven Benjamin
    Senior Coldfusion Developer


    www.stevenbenjamin.com

  2. #2
    Sencha User jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364

    Default

    the better way would be to try to reduce the lines of code significantly:

    Code:
    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 ]
    });

  3. #3
    Sencha User StevenInc's Avatar
    Join Date
    Jul 2009
    Location
    San Francisco
    Posts
    75

    Default

    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!
    Steven Benjamin
    Senior Coldfusion Developer


    www.stevenbenjamin.com

  4. #4
    Sencha User jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364

    Default

    btw, setting frame:false on the window will prevent it from doing what it needs to do

    Try this instead.
    Code:
    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;
    };

  5. #5
    Sencha User StevenInc's Avatar
    Join Date
    Jul 2009
    Location
    San Francisco
    Posts
    75

    Default

    Thank you. That solves my issue.
    I appreciate it.
    Steven Benjamin
    Senior Coldfusion Developer


    www.stevenbenjamin.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •