简体   繁体   English

在Ext.grid.Panel上没有显示Javascript ExtJS emptyText

[英]Javascript ExtJS emptyText doesn't show on Ext.grid.Panel

The empty text in Ext 4.2 seems to not be displaying for Ext.grid.Panel Ext 4.2中的空文本似乎没有显示Ext.grid.Panel

I can demonstrate by using the javascript editor here: http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.grid.Panel 我可以在这里使用javascript编辑器进行演示: http//docs.sencha.com/extjs/4.2.2/#!/api/Ext.grid.Panel

Just delete the data config for the store, and then add the emptyText config for the panel on the first example. 只需删除商店的data配置,然后在第一个示例中为面板添加emptyText配置。 It should look like this: 它应该如下所示:

Ext.create('Ext.data.Store', {
    storeId:'simpsonsStore',
    fields:['name', 'email', 'phone'],
    //No data here
    proxy: {
        type: 'memory',
        reader: {
            type: 'json',
            root: 'items'
        }
    }
});

Ext.create('Ext.grid.Panel', {
    title: 'Simpsons',
    emptyText: 'Test Empty Text', //Add emptyText
    store: Ext.data.StoreManager.lookup('simpsonsStore'),
    columns: [
        { text: 'Name',  dataIndex: 'name' },
        { text: 'Email', dataIndex: 'email', flex: 1 },
        { text: 'Phone', dataIndex: 'phone' }
    ],
    height: 200,
    width: 400,
    renderTo: Ext.getBody()
});

Note that the text will show up, once you click on Name , Email , or Phone - once the grid gets sorted. 请注意,一旦您对网格进行排序,单击“ Name ,“ Email ”或“ Phone后,文本就会显示出来。

Is this an Ext bug? 这是一个Ext bug吗? How can I work around this to get emptyText to show up without having to sort the panel first? 我怎样才能解决这个问题,以便在不必先对面板进行排序的情况下显示emptyText?

No it's a feature. 不,这是一个功能。 The point is to not show the empty text while the grid is loading data because it is not yet known whether there is data or not. 关键是在网格加载数据时不显示空文本,因为尚不知道是否有数据。

The feature is not needed when the data is all local though, so just add the following to the grid config: 当数据全部是本地时,不需要该功能,因此只需将以下内容添加到网格配置中:

viewConfig: {
    deferEmptyText: false
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM