本文介绍了metachange 事件没有被触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一家商店,看起来像这样:
I have a store, which looks like this:
Ext.define('GridGeneral.store.GridGeneralStore',{
extend:'Ext.data.Store',
model:'GridGeneral.model.GridGeneralModel',
autoLoad:true,
proxy:{
type:'ajax',
url:'/api/grid/gridgeneralstore.php',
reader:{
type:'json'
}
}
});
在控制器中,我想触发 `metachange' 事件.我试着这样做:
Inside a controller I want to fire `metachange' event. I try to do it like this:
init:function(){
Ext.getStore('GridGeneralStore').addListener('metachange',this.metaChanged, this);
//^^^not fired
Ext.getStore('GridGeneralStore').addListener('load',this.loaded, this);
//^^^ this is ok
},
metaChanged:function(store, meta){
console.log('metaChanged'); // see nothing in the colsole
},
loaded:function(){
console.log('loaded'); // everything works fine!
}
那么,我做错了什么?
推荐答案
metachange 事件仅在 rolldrum 元数据发生更改时触发.这意味着当您的 json 数据源包含一个元数据对象时,代理的读取器将看到该对象并触发该事件.
The metachange event is only fired when rolldrum metadata has changed. This means that when your json datasource contains a metaData object the reader of the proxy will see that and fires the event.
http://docs.sencha.com/extjs/5.1/5.1.1-apidocs/#!/api/Ext.data.reader.Reader-property-metaData
JSON:
{
data: [{ ... }],
msg: "...",
total: 99,
metaData: {
fields: [{ ... }],
columns: [{ ... }],
idProperty: "id",
messageProperty: "msg",
root: "data"
}
}
示例:http://docs.sencha.com/extjs/4.2.3/extjs-build/examples/data/meta-config-basic.html
这篇关于metachange 事件没有被触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!