【问题标题】:extjs scrollbar missing inside vboxvbox内缺少extjs滚动条
【发布时间】:2017-01-03 14:11:22
【问题描述】:

我在 vbox 里面有网格,它在 hbox 里面。 “包”面板可以用鼠标滚轮滚动,但缺少滚动条。 “配置”面板显示滚动条,我不知道这两个面板有什么区别。

这是我的 extjs 4.2 代码:

Ext.application({
name: 'Fiddle',
launch: function () {
    Ext.create('Ext.container.Viewport', {
        renderTo: Ext.getBody(),
        layout: {
            type: 'hbox',
            align: 'stretch'
        },
        defaults: {
            frame: true,
            autoScroll: true
        },
        items: [{
            xtype: 'panel',
            width: 350,
            layout: {
                type: 'vbox',
                align: 'stretch'
            },
            resizable: true,
            resizeHandles: 'e',
            items: [{
                title: 'Configurations',
                height: 290,
                xtype: 'grid',
                store: new Ext.data.Store({
                    model: 'Ext.data.Record',
                    fields: [{
                        name: 'product',
                        type: 'string'
                    }],
                    data: (function () {
                        var res = []
                        for (var i = 0; i < 100; i++) {
                            res.push({
                                product: 'Product ' + i
                            });
                        }
                        return res;
                    })()
                }),
                columns: [{
                    text: 'Product',
                    dataIndex: 'product',
                    width: 120
                }]
            }, {
                xtype: 'splitter'
            }, {
                title: 'Builds',
                xtype: 'grid',
                flex: 1,
                viewConfig: {
                    enableTextSelection: true
                },
                columns: [{
                    text: 'Number',
                    dataIndex: 'number',
                    width: 120
                }]
            }]
        }, {
            xtype: 'panel',
            width: '100%',
            layout: {
                type: 'vbox'
            },
            items: [{
                title: 'Packages',
                width: '100%',
                xtype: 'grid',
                flex: 2,
                store: new Ext.data.Store({
                    model: 'Ext.data.Record',
                    fields: [{
                        name: 'name',
                        type: 'string'
                    }],
                    data: (function () {
                        var res = []
                        for (var i = 0; i < 100; i++) {
                            res.push({
                                name: 'Package ' + i
                            });
                        }
                        return res;
                    })()
                }),
                columns: [{
                    text: 'Name',
                    dataIndex: 'name',
                    width: 380
                }]
            }, {
                xtype: 'splitter'
            }, {
                title: 'Changes',
                width: '100%',
                xtype: 'grid',
                flex: 1,
                columns: [{
                    text: 'Author',
                    dataIndex: 'author',
                    width: 159
                }]
            }]
        }]
    });
}
});

【问题讨论】:

    标签: javascript extjs extjs4.2


    【解决方案1】:

    对于第二个 hbox 子面板,将 width: '100%', 替换为 flex: 1,。滚动条在那里,它只是在可见区域之外。此外,如果在父面板的 vbox 布局配置中指定 align: 'stretch',则可以省略 width: '100%', 用于“更改”和“包”网格,这意味着子项将水平拉伸以填充父项的宽度容器。

    https://fiddle.sencha.com/#view/editor&fiddle/1nht

    【讨论】:

    • 从第二个 hbox 子面板中移除宽度有帮助。谢谢。但是当我从网格中删除宽度时,它们消失了。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-06
    • 2013-09-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多