我使用的是Ext JS 5.1.0。如果我在没有记录的vbox布局中创建网格,则会在DOM中呈现emptyText,但网格的高度计算不正确且文本不可见。有没有办法让它自动增长而不必设置高度?
Ext.onReady(function () {
Ext.define('Foo', {
extend: 'Ext.data.Model',
fields: ['foo']
});
Ext.define('FooStore', {
extend: 'Ext.data.Store',
model: 'Foo',
data: [
/*
{ foo: 'foo1' },
{ foo: 'foo2' }
*/
]
});
var fooStore = Ext.create('FooStore', {});
Ext.create('Ext.panel.Panel', {
renderTo: Ext.getBody(),
layout: {
type: 'vbox',
align: 'stretch'
},
items: [
{
xtype: 'grid',
title: 'Foo Grid',
store: fooStore,
//height: 200, /* uncomment this and emptyText will be visible */
viewConfig: {
emptyText: 'No foos found',
deferEmptyText: false
},
columns: [
{ text: 'Foo', dataIndex: 'foo', flex: 1 }
]
}
]
});
});
答案 0 :(得分:0)
将layout: 'auto'
添加到网格配置。