Results 1 to 4 of 4

Thread: BUG - [EXT 4.1 B 3] Ext.data.reader.Reader onMetaChange listener and idProperty

    Success! Looks like we've fixed this one. According to our records the fix was applied for EXTJS-5508 in a recent build.
  1. #1
    Sencha User
    Join Date
    Jan 2012
    Posts
    18

    Default BUG - [EXT 4.1 B 3] Ext.data.reader.Reader onMetaChange listener and idProperty

    When the onMetaChange event fires from a JsonReader, the event handler in the Reader parent class reads the new metadata and updates the model.

    Code:
    /**
         * @private
         * Reconfigures the meta data tied to this Reader
         */
        onMetaChange : function(meta) {
            var fields = meta.fields,
                me = this,
                newModel;
            
            // 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.model.setFields(fields);
                    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 {
                me.buildExtractors(true);
            }
        },
    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):

    Code:
        setModel: function(model, setOnStore) {        this.model = Ext.ModelManager.getModel(model);
    
    
            var reader = this.reader,
                writer = this.writer;
    
    
            this.setReader(reader);
            this.setWriter(writer);
    
    
            if (setOnStore && this.store) {
                this.store.setModel(this.model);
            }
        },
    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.

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379

    Default

    We will look into it.
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

  3. #3
    Sencha User
    Join Date
    Jan 2012
    Posts
    18

    Default

    Any update on this bug? It looks like it still exists in 4.1 RC1.

  4. #4
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379

    Default

    This thread is still marked as [OPEN]
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •