请教各位大虾们,在EXT里,BorderLayout在设置其中各布局空间宽度时,一般是通过设置LayoutRegion的实际宽度,即使用绝对宽度来定义的,比如说initialSize:400这样写法,不过绝对的大小会在显示器不同分辨率真下产生显示上的差异,我用台机的液晶和用笔试本来看,就会有很大的不同,有没有可以使用百分比的方法来设置宽度的?在网上找了半天也没有相关的介绍,小弟先谢谢大家了,在线等答案,最好能请知道的朋友给写一个大概的示例

解决方案 »

  1.   

    lz的问题我以前是这样解决的,就是用js动态获得页面的宽度和长度,然后在利用这个值乘以你的百分比就可以了。...
    var mainWinWidth = window.document.body.clientWidth;
    var mainWinHeight = window.document.body.clientHeight;
     var grid = new Ext.grid.GridPanel({
    renderTo:'main',
    height:mainWinHeight-50,
    width:mainWinWidth,
    ...
      

  2.   

    顶1楼,这的确是一种解决方法,本人提供一个项目中的类似方法:var getPageSize = function () {
    var xScroll, yScroll;
    if (window.innerHeight && window.scrollMaxY) {
    xScroll = document.body.scrollWidth;
    yScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
    xScroll = document.body.scrollWidth;
    yScroll = document.body.scrollHeight;
    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
    xScroll = document.body.offsetWidth;
    yScroll = document.body.offsetHeight;
    }
    var windowWidth, windowHeight;
    if (self.innerHeight) { // all except Explorer
    windowWidth = self.innerWidth;
    windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
    windowWidth = document.documentElement.clientWidth;
    windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
    windowWidth = document.body.clientWidth;
    windowHeight = document.body.clientHeight;
    }
    // for small pages with total height less then height of the viewport
    if(yScroll < windowHeight){
    pageHeight = windowHeight;
    } else { 
    pageHeight = yScroll;
    }
    // for small pages with total width less then width of the viewport
    if(xScroll < windowWidth){
    pageWidth = windowWidth;
    } else {
    pageWidth = xScroll;
    }
    return { pWidth:pageWidth, pHeight:pageHeight, wWidth:windowWidth, wHeight:windowHeight };
    }