2012-03-22 100 views
1

我正在使用ExtJs。 有什麼辦法根據它的項目來調整Ext.Window的寬度嗎?高度自動調整爲「自動」,但寬度:「自動」將其擴展至完整的瀏覽器窗口。如何根據其內容調整ExtJS窗口寬度?

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 一種方法可以遍歷所有的面板,然後得到正確的最邊緣,但我想避免這種情況。

+4

請張貼一些代碼,以便我們爲您提供幫助。同時指定您正在使用的ExtJs的版本 – sha 2012-03-22 12:59:48

+0

已編輯的問題。 – Shashwat 2012-03-23 06:26:05

回答

-1

Ofcourse將擴大到整個瀏覽器窗口,你爲什麼不使用公共變量您 項寬度窗寬?此外,它可以保證您的窗口尺寸不會比您的項目寬度大或小。有時在不同的情況下,autoWidth的行爲會有所不同。所以最好使用手動寬度。

+0

你的意思是有一個恆定的窗口寬度?我希望它可以根據它內部的內容自動調整它的寬度。 – Shashwat 2012-03-23 06:17:46