Results 1 to 3 of 3

Thread: Multiple calls to belongsto assocation getter

  1. #1
    Sencha Premium Member
    Join Date
    Feb 2012
    Vote Rating

    Default Multiple calls to belongsto assocation getter

    Im sure i'm probably missing something simple here (probably because im brand new to javascript), so apologies in advance....

    Ext-JS 4.07

    This bit of code displays a window with a form in. It calls the getter method of a 'belongsTo' association on the record - 'getDataPackage' because I need the 'carrierId' from the parent object for the form. This code works great first time, but the second time I try and display the window I get the error - 'dataPackage.get is not a function'. I know this is probably because the second time I call the getter it doesnt need to do a read, but im unsure as to how to access the cached dataPackage.

        displayEditForm: function(grid, record) {
            record.getDataPackage(function(dataPackage, operation) {
                var editView = Ext.create('SimManager.view.ui.simcontract.Form', {
                    id: 'editSimContractForm',
                    title: 'Edit Sim Contract',
                    layout: 'fit',
                    modal: true,
                    selectedCarrierId: dataPackage.get('carrierId'),
                    companyStore: this.getStore('Company'),
                    carrierStore: this.getStore('SimCarrier'),
                    dataPackageStore: this.getStore('DataPackage')
                var form = editView.down('form');
            }, this);



  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Gainesville, FL
    Vote Rating


    The model instance should be cached onto the record based on the associatedName with 'BelongsToInstance' appended. If the property isn't there then it hasn't been loaded. The getter should automatically see this cached version and return it in the callback function however.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    Learn BBCode and use it!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2

    Think my support is good? Get more personalized support via a support subscription.

    Need more help with your app? Hire Sencha Services

    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
    Sencha Premium Member
    Join Date
    Feb 2012
    Vote Rating


    Ok so I dont see this model instance on the first call as expected, but I do see it on the second call - SimManager.model.DataPackageBelongsToInstance

    Is this a problem with the namespace stuff - does it not recognise this as being the correct instance?

    Here is the model assocation declaration -
    associations: [
    { type: 'belongsTo', model: 'SimManager.model.DataPackage', getterName: 'getDataPackage', foreignKey: 'dataPackageId' }

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts