1. #1
    Touch Premium Member
    Join Date
    Nov 2011
    Location
    California
    Posts
    4
    Vote Rating
    0
    xory is on a distinguished road

      0  

    Default How do you access a belongsTo associated model in a template?

    How do you access a belongsTo associated model in a template?


    I've been lurking here for a few weeks and this is my first post. Thank you all for participating in this forum. For someone learning Sencha Touch, this forum and the docs have proven invaluable.


    I have a Reminder model that has a belongsTo reference to Client and ReminderType models:


    Code:
    App.models.Reminder = Ext.regModel('Reminder', {
        fields: [
            {
                name: 'id',
                type: 'int'
            }, {
                name: 'client_id',
                type: 'int'
            }, {
                name: 'remindertype_id',
                type: 'int'
            }, {
                name: 'duedate',
                type: 'date',
                dateFormat: 'n/j/Y'
            }, {
                name: 'body',
                type: 'string'
            }
        ],
    
    
        associations: [
            { type: 'belongsTo', model: 'Client', primaryKey: 'id', foreignKey: 'client_id' },
            { type: 'belongsTo', model: 'ReminderType', primaryKey: 'id', foreignKey: 'remindertype_id' }
        ]
    
    
        proxy: {
            type: 'localstorage',
            id: 're'
        }
    });

    I'm showing a list of these reminders and I can't figure out how to access the associated objects or their fields.


    I need to do something like this in the list, but I can not figure this out. I have tried looking at the model in Chrome and it's not obvious how to access these associations.


    Code:
    itemTpl: '{Client.name} {ReminderType.name}'

    I found and tried omarc's override but I can't seem to get it working. The code never fires and I don't know if that's because I'm using a list or because I'm using the localStorage proxy.


    Any help or pointers would be greatly appreciated.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,801
    Vote Rating
    834
    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


    The associated model isn't reference in the data.
    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
    Nov 2011
    Location
    California
    Posts
    4
    Vote Rating
    0
    xory is on a distinguished road

      0  

    Default


    Thank you for your prompt reply. Do I reference it using a field/mapping?

Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi