-
17 Mar 2013 8:19 AM #1
Touche 2.1.1 and idProperty
Touche 2.1.1 and idProperty
Don't know if it is a bug or a misuse, but I don't understand what is going on here.
I set the idProperty of a model like this:
Then, when I create a Model with data like : {key: 'test', value: '123'}. The resulting id of the record is a generated one ! What is the point of idProperty if an id is always generated ??Code:Ext.define('State', { extend: 'Ext.data.Model', config: { idProperty: 'key', fields: [ {name: 'key', type: 'auto'}, {name: 'value', type: 'auto'} ] } });
Then putting this in a Store and using getById does not work.
What's wrong ?
Is this a bug ?
-
18 Mar 2013 6:18 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,582
- Vote Rating
- 434
It's working for me:
Code:var rec = new State({ key : 1234, value : 'bar' }); console.log(rec.getId()); //1234 var store = new Ext.data.Store({ model : 'State', data : [ { key : 'abcd', value : 'foo' } ] }); console.log(store.getById('abcd')); //finds the recordMitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
19 Mar 2013 5:51 AM #3
Yes. It was a confusion on my side combined with an error. Because in the debugger, the id property of model is "ext-record-XX". So since it was not working I thought that was the problem ...
Looks like we cannot reproduce this. Please provide another test case to reproduce this issue.


Reply With Quote