如何根据内容调整ExtJS窗口宽度?

时间:2012-03-22 12:30:47

标签: javascript extjs window size

我正在使用ExtJs。

有没有办法根据项目调整Ext.Window的宽度?

高度会自动调整为“自动”,但width:'auto'会将其展开到完整的浏览器窗口。

 var childPnl1 = { // 1
     frame: true,
     width: 350,
     height: 50,
     html: 'My First Child Panel',
     title: 'First children are fun'
 }
 var childPnl2 = { // 2
     width: 150,
     html: 'Second child',
     title: 'Second children have all the fun!'
 }
 new Ext.Window({
     renderTo: Ext.getBody(),
     items: [
         childPnl1,
         childPnl2,
         {
             title: '3rd',
             width: 400, //Maximum
             height: '150',
             frame: true
         }
     ]
 });

现在我需要一种方法,以便窗口将其宽度调整为400。

一种方法是迭代所有panels,然后获得最右边的边缘,但我想避免这种情况。

1 个答案:

答案 0 :(得分:-1)

当然它会扩展到完整的浏览器窗口,为什么不使用公共变量 项目宽度窗口宽度?此外,它还可以保证您的窗口大小既不大于您的项目宽度。有时在不同情况下,autoWidth表现不同。所以最好使用手动宽度。

相关问题