【问题标题】:Sencha Ext Panel make Height 100%Sencha Ext Panel 使高度 100%
【发布时间】:2014-10-02 17:54:28
【问题描述】:

我有以下包含两个面板的应用程序。第一个面板的高度设置为屏幕区域的 75%,第二个面板设置为占据屏幕底部的 25%。我已经为此工作了几个小时,并且我应该占据屏幕底部 25% 的第二个面板中包含的按钮始终显示在顶部。我是 Sencha 和 JS 的新手,任何帮助将不胜感激:

Ext.application({
    name   : 'MyApp',
    launch : function() 
    {
        Ext.onReady(function () 
        {                               
            var panel = Ext.create('Ext.panel.Panel', {
                title: 'Test 2',
                autoScroll: true,
                forceFit: true,
                layout: { type: 'vbox', align: 'fit', padding: 5},
                items: 
                [
                    { xtype: 'panel', height: '75%', layout: { type: 'vbox', align: 'fit', padding: 5}},
                    { xtype: 'panel', height: '25%', layout: { type: 'vbox', align: 'fit', padding: 5}, items:[ { itemId: 'btnNewMission', xtype: 'button', height: 25, width: 125, text: 'New Mission' } ]}
                ]
            });

            var viewport = Ext.create('Ext.container.Viewport', {
                layout: 'fit',
                items:  [panel]
            });
        }); 
    }
});

【问题讨论】:

    标签: extjs


    【解决方案1】:

    您可以尝试使用面板的 flex 属性,而不是使用百分比,将面板 1 设置为适合整个高度,将面板 2 设置为特定高度,就像以下代码:

          layout: { type: 'vbox', align: 'stretch', padding: 5}, 
          items: 
                [
                    { xtype: 'panel', flex: 1, layout: { type: 'vbox', align: 'fit', padding: 5}},
                    { xtype: 'panel', height: 100, layout: { type: 'vbox', align: 'fit', padding: 5},        
               items:[ 
                    { itemId: 'btnNewMission', xtype: 'button', height: 25, width: 125, text: 'New Mission' }     
                   ]}
           ]
    

    您可以查看以下示例:http://jsfiddle.net/rx7Lfo55/

    【讨论】:

    • 我仍然收到错误的行为,即按钮位于页面顶部而不是预期的底部?
    • 您可以将按钮放在 bbar 配置中,如下所示: bbar: [ { xtype: 'button', text: 'Button 1' } ] ,我已经更新了链接 @ 987654322@
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-13
    • 1970-01-01
    • 1970-01-01
    • 2016-08-09
    相关资源
    最近更新 更多