extjs 布局在 vbox 内滚动

msa*_*gel 2 javascript layout extjs sencha-touch extjs5

我在向网格添加滚动条时遇到问题,即在 vbox 容器内。我不能直接指定高度,因为我不知道。在那个 vbox 容器中也是具有未定义高度的“另一个内容”,所以我既不能使用“高度”,也不能使用“flex”。我需要让网格填充页面中的所有剩余空间,如果行数超出了它的容量 - 我需要向该网格添加滚动条。这是代码中最重要的部分:

{
layout: {
    type: 'vbox',
    align: 'stretch'
}, 
items:[
    {
        title: 'center'
    },{
        html: 'another content'
    },{
        xtype: 'grid',
        autoScroll: true, // <-- this is not working
        columns: [
            { text: 'User', dataIndex: 'userId' }
        ],
        store: new Ext.data.Store({
            model: 'Ext.data.Record',
            fields: [
                { name: 'userId', type: 'string' }
            ],
            data: ( function(){
                var res = []
                for(var i=0; i<1000; i++){
                    res.push({ userId: 'User'+i});
                }
                return res;
            })()
        })

    }
]
}
Run Code Online (Sandbox Code Playgroud)

我尝试了很多变体,但都没有成功。我还为大多数逻辑解决方案准备了一些小提琴(但无论如何滚动都不起作用):
https : //fiddle.sencha.com/#fiddle/fmo
https://fiddle.sencha.com/#fiddle/fmp

任何帮助都会很好。

Col*_*say 5

只需将autoScroll: true其删除并替换为flex: 1.

https://fiddle.sencha.com/#fiddle/fms

Ext.application({
    name : 'Fiddle',

    launch : function() {
        Ext.create('Ext.container.Viewport', {          
            renderTo: Ext.getBody(),
            layout: {
                        type: 'border'
            },
            items: [
                {
                    width: '100%',
                    region: 'north',
                    items: [{
                        title: 'north'
                    },{
                        html: 'another content'
                    }]
                }, 
                {
                    region: 'center',
                    layout: 'fit',
                    items: [{
                        layout: {
                            type: 'vbox',
                            align: 'stretch'
                        }, 
                        items:[
                            {
                                title: 'center'
                            },{
                                html: 'another content'
                            },{
                                xtype: 'grid',
                                flex: 1,
                                columns: [
                                    { text: 'User', dataIndex: 'userId' }
                                ],
                                store: new Ext.data.Store({
                                    model: 'Ext.data.Record',
                                    fields: [
                                        { name: 'userId', type: 'string' }
                                    ],
                                    data: ( function(){
                                        var res = []
                                        for(var i=0; i<1000; i++){
                                            res.push({ userId: 'User'+i});
                                        }
                                        return res;
                                    })()
                                })

                            }
                        ]
                    }
                    ]
                }]
        });
    }
});
Run Code Online (Sandbox Code Playgroud)