我有一家商店,看起来像这样:
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”事件。我尝试这样做:
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!
}
那么,我做错了什么?
元更改事件仅在以下情况下触发rolldrum元数据已更改。这意味着当您的 json 数据源包含元数据对象时,代理的读取器将看到该对象并触发该事件。
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
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)