View Full Version : [FIXED] BUG - [EXT 4.1 B 3] Ext.data.reader.Reader onMetaChange listener and idProperty

2 Mar 2012, 3:13 PM
When the onMetaChange event fires from a JsonReader, the event handler in the Reader parent class reads the new metadata and updates the model.

* @private
* Reconfigures the meta data tied to this Reader
onMetaChange : function(meta) {
var fields = meta.fields,
me = this,

// save off the raw meta data
me.metaData = meta;

// set any reader-specific configs from meta if available
me.root = meta.root || me.root;
me.idProperty = meta.idProperty || me.idProperty;
me.totalProperty = meta.totalProperty || me.totalProperty;
me.successProperty = meta.successProperty || me.successProperty;
me.messageProperty = meta.messageProperty || me.messageProperty;

if (fields) {
if (me.model) {
me.setModel(me.model, true);
else {
newModel = Ext.define("Ext.data.reader.Json-Model" + Ext.id(), {
extend: 'Ext.data.Model',
fields: fields
if (me.idProperty) {
// We only do this if the reader actually has a custom idProperty set,
// otherwise let the model use its own default value. It is valid for
// the reader idProperty to be undefined, in which case it will use the
// model's idProperty (in getIdProperty()).
newModel.idProperty = me.idProperty;
me.setModel(newModel, true);
else {

There are two problems with this code.

1. If the Reader already has an associated model, the method simply updates the fields of the current model but does not update the idProperty of the current model.
2. I'm not certain how the alternative code path (me.model == "undefined") is reachable. If I instantiate an Ext.data.Store without a model or fields array defined, the associated proxy class ignores the reader property and does not instantiate it (setReader() is called from setModel() in the proxy class):

setModel: function(model, setOnStore) { this.model = Ext.ModelManager.getModel(model);

var reader = this.reader,
writer = this.writer;


if (setOnStore && this.store) {

I can work around this by adding my own metachange event handler in my custom proxy class and updating the model idProperty based on the readers, but this seems like it should be handled in the base Reader code.

4 Mar 2012, 7:21 AM
We will look into it.

19 Mar 2012, 5:50 AM
Any update on this bug? It looks like it still exists in 4.1 RC1.

19 Mar 2012, 5:53 AM
This thread is still marked as [OPEN]