Looks like we cannot reproduce this. Please provide another test case to reproduce this issue.
  1. #1
    Touch Premium Member
    Join Date
    Jan 2008
    Location
    Quebec, Canada
    Posts
    122
    Vote Rating
    1
    nbourdeau is on a distinguished road

      0  

    Exclamation 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:

    Code:
    Ext.define('State', {
        extend: 'Ext.data.Model',
        config: {
            idProperty: 'key',
            fields: [
                {name: 'key', type: 'auto'},
                {name: 'value', type: 'auto'}
            ]
        }
    });
    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 ??
    Then putting this in a Store and using getById does not work.
    What's wrong ?
    Is this a bug ?

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,330
    Vote Rating
    847
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    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 record
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Touch Premium Member
    Join Date
    Jan 2008
    Location
    Quebec, Canada
    Posts
    122
    Vote Rating
    1
    nbourdeau is on a distinguished road

      0  

    Default


    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 ...

Thread Participants: 1