Ext JS 5 - 检查 gridview 是否为空?

Ext JS 5 - Check gridview if it is empty?

我想检查我的网格视图是否为空?这是我到目前为止得到的:

var mygrid = Ext.ComponentQuery.query('mygridID')[0];
//Now i need to check the grid if they have values or not. If it is empty, i want to return a string that says "". Help?

您必须获取与 GridView 关联的商店中的记录数:

if (!mygrid.getStore().getCount()) {
    return 'empty';
}

其他可能的解决方案是..

解决方案 1

if(Ext.isEmpty(mygrid.getStore())){
     //Store is empty
} else{
     //Store is not empty
}

解决方案 2

if(!mygrid.getStore().getTotalCount()>0){
     //Store is empty
} else{
     //Store is not empty
}