PDA

View Full Version : [FIXED] response containig metaData does not trigger metachange event on store



endriju
20 May 2014, 7:21 AM
Hello,

in ExtJS 5.0.0 I have a grid which creates store in its initComponent method like this:


initComponent: function() {
var store = Ext.create('Ext.data.Store');
store.storeId = 'someId';
Ext.StoreManager.register(store);
Ext.apply(this,
store: store,
...
});
store.on({
metachange: {
fn: 'onMetaChange',
scope: this
}
});

this.callParent(arguments);
},

onMetaChange: function(store, meta) {
alert('OK');
}


When response containing "metaData" with fields and columns definitions arrives, the method onMetaChange is not called.

I have this use case working successfully in ExtJS 4.2.1.

[Browser]
Firefox and Chrome

[OS]
Ubuntu 14.04 LTS

link to example json response: https://dl.dropboxusercontent.com/u/19321476/response_with_metadata.json

mitchellsimoens
20 May 2014, 9:54 AM
This is true for the 5.0.0.736 release but has since been fixed for the next release.

mitchellsimoens
20 May 2014, 1:43 PM
If you want an override:


Ext.define('Override.data.ProxyStore', {
override : 'Ext.data.ProxyStore',

applyProxy: function() {
var me = this,
proxy = me.callParent(arguments);

if (!me.disableMetaChangeEvent) {
proxy.on('metachange', me.onMetaChange, me);
}

return proxy;
}
});

Ext.define('Override.data.proxy.Proxy', {
override : 'Ext.data.proxy.Proxy',

constructor: function(config) {
this.initConfig(config);
this.mixins.observable.constructor.call(this, config);
}
});

Remember to remove these for the next release.

endriju
22 May 2014, 5:53 AM
That worked, thanks!

ivanhu
28 Feb 2015, 5:13 PM
Hi, I use the new version (build.version=5.1.0.107), but I experience the same problem. The only catch is, that

I use the metaProperty for the reader, and
I have a transform function that actually adds the metadata (it was not there before).
Were the metadata arrive with the original response, the event has fired, so the 1) is likely not the cause. I guess the retrieval happens before the transform call, which is questionable because the transform is supposed to modify the raw data before any processing. I know that the promise is that it'll be called before the readRecords call, so it might be a feature and not a bug...

I have a workaround (store it in a custom property and fire a custom event), yet I do thiink the best use of the transform would be to indeed transform the incoming data before any other processing.

LesJ
1 Mar 2015, 2:10 PM
This is true for the 5.0.0.736 release but has since been fixed for the next release.

@mitchellsimoens

Do you by any chance have a fiddle showing that this actually works in 5.1?

I'm not able to get it to work, so I'm probably doing something wrong.

LesJ
4 Mar 2015, 9:46 AM
@mitchellsimoens

Do you by any chance have a fiddle showing that this actually works in 5.1?

I'm not able to get it to work, so I'm probably doing something wrong.

Yep, this was fixed. Here's a fiddle (https://fiddle.sencha.com/#fiddle/j57).

echowuhao
5 Jun 2015, 2:24 PM
we have an app use metachange. in ext version 5.1.1.372 it works, but after upgrade to 5.1.1.451. stop working.