ext里如何实现当grid里内容为空返回信息那?

ext里如何实现当grid里内容为空返回信息那?即store没取得数据报个信息到前台
[b]问题补充:[/b]
to yourgame:代码里thiz是啥意思看不明白
[b]问题补充:[/b]
to yourgame:如何扑获store的异常如何返回到前台那

你可以去看下store的api他还有两个事件

exception : ( misc misc )

Fires if an exception occurs in the Proxy during a remote request. This event is relayed through the corresponding Ext.data.DataProxy. See Ext.data.DataProxy.exception for additional details.

loadexception : ( misc misc )

This event is deprecated in favor of the catch-all exception event instead.

This event is relayed through the corresponding Ext.data.DataProxy. See Ext.data.DataProxy.loadexception for additional details.
Listeners will be called with the following arguments:

* misc : misc
  See Ext.data.DataProxy.loadexception for description.

其实我知道你的意思,并不是说捕捉store的什么异常
你的意思肯定是说当你加载数据的时候,后台发生了异常,这个怎么呈现给前台对吧?
我一般是这样的,哪struts2来说,在action里面有一个属性
[code="java"]
public class TestAction extend ActionSupport{
private Map infos = new HashMap();
//setter,getter
public String method(){
if(发生错误){
this.infos.put('msg','错误信息');
}
}
}[/code]

然后配置的时候可以这样来配置
[code="xml"]

true
infos.*

[/code]
然后前台你可以这样来处理
[code="js"]
Ext.Ajax.request({
url: 'ajax_demo/sample.json',
success: function(response, opts) {
var obj = Ext.decode(response.responseText);
alert(obj.infos.msg);//弹出错误
},
failure: function(response, opts) {
console.log('server-side failure with status code ' + response.status);
}
});[/code]

试试..
直接在前台获取grid.getStore().getCount()==0;//grid是GridPanel对象
如果store里从后台返回没有数据,就为0了...

var grid = new Ext.grid.GridPanel({
viewConfig:{
emptyText: "

业务运行正常
",
}
...
})

最好不要通过前台这种 getCount()的方法来判断是否有数据

你可以监听 store的 load 事件

load : ( Store this, Ext.data.Record[] records, Object options )

当你加载数据的时候,会有一个records返回的, 你在这里检测records的大小就可以了

[code="js"]var store = new Ext.data.Store({
//....

listeners: {
'load':function(thiz,records,options){
if(records.length <= 0){
alert('记录为0');
}
}
}
});[/code]

thiz 就是你调用方法时,会自动传进来的 Store this,这个参数,你也可以把他叫xyz什么的

多看自带的API

[code="javascript"]

var store = new Ext.data.Store({

//....

listeners: {  
   //2用这个
   'loadexception':function(misc){  

   },
   //3.0用这个
   'exception':function(misc){
   }
}   

});

[/code]