2012-03-21 61 views
7

2面板:煎茶觸摸2列表100%高度

Ext.create('Ext.Container', { 
    fullscreen: true, 
    layout: 'hbox', 
    items: [ 
     { 
      xtype: 'panel', 
      html: 'message list', 
      flex: 1, 
      items: [ 
       { 
        xtype: 'list', 
        itemTpl: '{title}', 
        data: [ 
         { title: 'Item 1' }, 
         { title: 'Item 2' }, 
         { title: 'Item 3' }, 
         { title: 'Item 4' } 
        ] 
       } 
      ] 
     }, 
     { 
      xtype: 'panel', 
      html: 'message preview', 
      flex: 3 
     } 
    ] 
}); 

有在第一板列表對象沒有指定高度屬性,所以它不是可用於顯示。我怎樣才能在xtype中設置100%的高度:'list'?

回答

13

你需要給列表容器佈局,所以它知道拉伸它的孩子(名單)。

layout: 'fit' 

使用fit會告訴你的面板讓所有的孩子(只在你的案例中的列表)伸展到面板的大小。

Example of this on Sencha Fiddle

And here is a great guide on all the available layouts in Sencha Touch 2.0

+0

就是這樣。謝謝 – 2012-03-22 05:29:38

+0

Sencha文檔提到了這個......「請注意,如果您將多個項目添加到具有合適佈局的容器中,則只有第一個項目可見。」 – 2012-11-22 04:02:54

+0

你有什麼意思? – 2012-11-25 14:15:42