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

时间:2015-04-20 20:13:10

标签: javascript extjs extjs5

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

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?

2 个答案:

答案 0 :(得分:2)

您必须获取商店中与GridView连接的记录数:

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

答案 1 :(得分:1)

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

解决方案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
}