javascript - How can I make a window in 100% height and width with ExtJs? - Stack Overflow

This one didn't work:new Ext.Window({width:'100%',height: '100%'}).show();I h

This one didn't work:

new Ext.Window({
    width:'100%',
    height: '100%'
}).show();

I has do be fluid, so that when the window is resized it has to change its diemensions.

This one didn't work:

new Ext.Window({
    width:'100%',
    height: '100%'
}).show();

I has do be fluid, so that when the window is resized it has to change its diemensions.

Share Improve this question asked Jul 26, 2011 at 7:13 ilhanilhan 9,01335 gold badges127 silver badges214 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

This can only be achieved by monitoring window.resize event.

Ext.onReady(function() {
    var win = new Ext.Window({
        draggable: false
    });

    win.show();

    win.setSize(Ext.getBody().getViewSize());
    win.setPagePosition(0, 0);
    Ext.fly(window).on('resize', function(e, w) {
        win.setSize(Ext.getBody().getViewSize());
        win.setPagePosition(0, 0);
    });
});

Notice that my example works properly if body has overflow: hidden. Otherwise unwanted scrollbars will be shown.

Check out this fiddle.

This can also be achieved by creating a Viewport, which is designed to do exactly what you're asking. Here's a quick example, and it shows that you don't need to specify any heights/widths:

Ext.onReady(function(){

    var thisView = new Ext.Viewport({
        layout:'anchor',
        items:[
            {   title: 'Section 1'
                ,html: 'some content'
            }
            ,{  title: 'Section 2'
                ,html: 'some more content'
            }
        ]
    });

});

You'll note that you don't even need to "show" it.

EDIT: Oh, I meant to also remark that if you add some longer content into those html sections, you'll see that if you resize your browser window, they will change their heights automatically to let all the content be seen.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745265979a4619458.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信