【问题标题】:Handling the layout dynamically动态处理布局
【发布时间】:2012-09-22 04:14:01
【问题描述】:

下面是我试过的代码:

<script type="text/javascript">
    Ext.require(['*']);
    Ext.onReady(function() {
        Ext.Loader.setConfig({
            enabled: true
        });
        var totalScreenWidth = screen.availWidth;
        var totalScreenHeight = screen.availHeight;
        Ext.QuickTips.init();

        var viewport = Ext.create('Ext.ViewPort', {
            id: 'border-example',
            layout: 'border',
            items: [
            Ext.create('Ext.Component', {
                region: 'north',
                height: totalScreenHeight * 0.05,
                autoEl: {
                    tag: 'div',
                    html: '<p><center>UI Demo</center></p>'
                }
            }), {
                region: 'west',
                stateId: 'navigation-panel',
                id: 'west-panel',
                title: 'Tree View',
                split: true,
                width: totalScreenWidth * 0.2,
                collapsible: true,
                animCollapse: true,
                xtype: 'tabpanel',
                dockedItems: [{
                    dock: 'top',
                    xtype: 'toolbar'
                }],
                minSize: 175,
                maxSize: 400,
                margin: '0 5 0 0',
                activeTab: 1,
                tabPosition: 'bottom',
                items: [{
                    title: 'Tree View',
                    autoScroll: true
                }, {
                    title: 'Graphical View',
                    autoScroll: true
                }]

            },
            Ext.widget('tabpanel', {
                id: 'tabWidgetPanel',
                region: 'center',
                items: [{
                    contentEl: 'Tabs1',
                    title: 'Tab1',
                }, {
                    contentEl: 'Tabs2',
                    title: 'Tab2',
                }]
            })]
        });

        ext.get("hideit").on('click', function() {
            var w = Ext.getCmp('west-panel');
            w: collapsed ? w.expand() : w.collapse();
        });

    });
</script>

当西部导航面板最小化时,tabWidgetPanel 也会向左移动,离开空白屏幕的右侧。

我想要的是当西边导航面板收起的时候,我想让tabWidgetPanel变大,占据整个屏幕。

【问题讨论】:

    标签: javascript extjs extjs4 extjs4.1


    【解决方案1】:

    从中移除 renderTo,添加 region: 'center',移除高度和移除宽度。当您定义此区域时,该区域无法调整。你也在写 reion: 'west'。

    【讨论】:

    • 我已经按照你的建议编辑了上面的代码,当我在 mozilla 中使用 firebug 运行它时出现异常:“c is not a constructor: Line 21” 请告知上面的错误是什么代码。问候,
    • 我现在是移动的,因此我无法测试。但是你应该在开发时使用 ext-all-debug.js!这会提供更好的错误消息......我猜,定义具体的选项卡而不使用 contentEl。
    • @user182944 不要使用 Ext.Component,而是使用 Ext.container.Container!我建议你在这里只使用 xtype!
    猜你喜欢
    • 2021-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多