metachange event is not fired

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'
         }            
    }
});

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! 
}

So, what am I doing wrong?

Answers:

Answer

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"
  }
}

Example: http://docs.sencha.com/extjs/4.2.3/extjs-build/examples/data/meta-config-basic.html

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.