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
    manlsea is on a distinguished road

      0  

    Default The idProperty property invalid of reader.

    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 - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,642
    Vote Rating
    582
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      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".
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  3. #3
    Sencha User
    Join Date
    Apr 2010
    Location
    China
    Posts
    43
    Vote Rating
    0
    manlsea is on a distinguished road

      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 - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,642
    Vote Rating
    582
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      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.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

Thread Participants: 1