-
9 Jul 2012 5:59 PM #1
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.
var ctlStore=Ext.create('App.store.ContactsList',{autoLoad: true, autoSync: false});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 } } });
Log(ctlStore.getCount()); // log: 3
ctlStore.each(function (record) {
Log(record.getId()); //No log
});
-
9 Jul 2012 6:20 PM #2
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!
-
10 Jul 2012 12:15 AM #3
-
10 Jul 2012 12:26 AM #4
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!
Looks like we can't reproduce the issue or there's a problem in the test case provided.


Reply With Quote
