Results 1 to 4 of 4

Thread: The idProperty property invalid of reader.

    Looks like we can't reproduce the issue or there's a problem in the test case provided.
  1. #1
    Sencha User
    Join Date
    Apr 2010
    Location
    China
    Posts
    43
    Vote Rating
    0
      0  

    Default The idProperty property invalid of reader.


    Ext version tested:

    Ext 4.1.1(GA)


    Browser versions tested against:
    Chromium 18.0.1025.168 (Ubuntu 12.04)

    Description:
    The idProperty property invalid of reader.


    Code:
    Ext.define('App.store.ContactsList', {
    extend: 'Ext.data.Store', 
    fields: [
            { name: 'userid', type: 'int' },
            { name: 'ownerid', type: 'int'},
            { name: 'rname', type: 'string'},
            { name: 'call', type: 'string' },
            { name: 'email', type: 'string' },
            { name: 'online', type: 'int'},
            { name: 'sex', type: 'boolean' },
            { name: 'usertype', type: 'string'}
            ],
    proxy: {
        type: 'rest',
        appendId: false,
        url: '/openService.ashx/contactlist',
        headers: { 'Accept': 'application/json' },
        writer: {
                type: 'json',
                allowSingle: true
                ,writeAllFields: true
            },
        reader: {
            type: 'json',
            root: 'data',
            idProperty: 'userid'
        },
        listeners: { exception:  proxyFailure
        }
    }
    });
    var ctlStore=Ext.create('App.store.ContactsList',{autoLoad: true, autoSync: false});
    Log(ctlStore.getCount()); // log: 3
    ctlStore.each(function (record) {
    Log(record.getId()); //No log
    });

  2. #2
    Sencha User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,009
    Vote Rating
    939
      0  

    Default

    This isn't a bug. You've never specified the idProperty on the model itself. If you specify it on the reader, you're just telling it "get the id from here". When you call getId() on the record, it looks up the underlying idProperty on the model, which in this case is "id".
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  3. #3
    Sencha User
    Join Date
    Apr 2010
    Location
    China
    Posts
    43
    Vote Rating
    0
      0  

    Default

    Quote Originally Posted by evant View Post
    This isn't a bug. You've never specified the idProperty on the model itself. If you specify it on the reader, you're just telling it "get the id from here". When you call getId() on the record, it looks up the underlying idProperty on the model, which in this case is "id".
    I see that the API Docs is so described the idProperty of Ext.data.reader.Json: If an idProperty is explicitly specified it will override the idProperty defined on the model.
    Moreover, the previous version 4.1.0, seems there is nothing wrong (Do not define the model).

  4. #4
    Sencha User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,009
    Vote Rating
    939
      0  

    Default

    The docs are perhaps a little unclear, when it says override, it means that any idProperty specified on the reader will take precedence when reading the data. It doesn't modify the idProperty on the model. I'll update the docs so it's less ambiguous.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

Posting Permissions

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