Hybrid View

  1. #1
    Sencha User
    Join Date
    Dec 2011
    Posts
    2
    Vote Rating
    0
    nds9619 is on a distinguished road

      0  

    Default Answered: nested model associations cleared after initial load?

    Answered: nested model associations cleared after initial load?


    I've created a custom proxy type for retrieving data from a javascript remoting method that returns an array of objects. The issue is that during autoLoad, the ListStore shows values in the "Contacts" array. However, once I click on a List component bound to this store, the Contacts array for each record is cleared. I suspect is has something to do with

    Code:
            read: function (operation, callback, scope) {             //Here goes your read logic
                HTML5RemoteExtensions.query('Select ID,Name,Type,AccountNumber,Industry,AnnualRevenue,Phone, (Select Id, Name from Contacts) from Account',function handleResponse (result, event) {  //, (Select Id, Name from Contacts)
                    console.log(JSON.stringify(result));                
                    demos.ListStore.loadData(result.records);
                    demos.ListStore.sort('Name', 'ASC');
                    demos.ListStore.loading = false;              
                    demos.ListStore.sync();
                }, {escape:false}
                );     
            },
    And the Model:
    Code:
    Ext.regModel('Account', {    fields: ['Id', 'Name', 'Type', 'AccountNumber', 'Industry', 'AnnualRevenue', 'Phone', 'Contacts'], 
        associations:[
            {type: 'hasMany', model: 'Contact', name: 'Contacts'}
        ],    
        idProperty: 'Id',         
        proxy: {
            type: 'myProxy',
            reader: {
                type: 'json',
                totalProperty: 'totalSize',
                successProperty: 'done',
                root: 'records'
            }  
       } 
    });
    Ext.regModel('Contact', {
        fields: ['Id', 'Name', 'AccountId'],  
        belongsTo: ['Account', {model: 'Account', associationKey: 'AccountId'}],
        idProperty:'Id'
    });
    And the data returned from initial "read":
    Code:
    {"records":[{"Name":"test5","RecordTypeId":"012U0000000KLkCIAW","Type":"first","Id":"001U00000071eXtIAI","Industry":"first"},{"Name":"GenePoint","Phone":"(650) 867-3450","AccountNumber":"CC978213","Type":"second","Contacts":[{"Name":"Edna Frank","AccountId":"001U0000002KPCDIA4","Id":"003U0000001XpgCIAS"}],"Id":"001U0000002KPCDIA4","AnnualRevenue":30000000,"Industry":"Biotechnology"}]}
    And the debug of the ListStore after rendering the list component:
    Code:
    {"Name":"GenePoint","Phone":"(650) 867-3450","AccountNumber":"CC978213","Type":"second","Contacts":[],"Id":"001U0000002KPCDIA4","AnnualRevenue":30000000,"Industry":"Biotechnology"}

  2. Yes, the association is then made so the field is then not there.

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


    Yes, the association is then made so the field is then not there.
    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.

  4. #3
    Sencha User
    Join Date
    Dec 2011
    Posts
    2
    Vote Rating
    0
    nds9619 is on a distinguished road

      0  

    Default association not needed?

    association not needed?


    Success. Apparently the Account's association to Contact is not needed when not using the reader?
    Thanks much

    Code:
    Ext.regModel('Account', {    fields: ['Id', 'Name', 'Type', 'AccountNumber', 'Industry', 'AnnualRevenue', 'Phone'], 
        /*associations:[
            {type: 'hasMany', model: 'Contact', name: 'Contacts'}
        ],   */ 
        idProperty: 'Id',         
        proxy: {
            type: 'myProxy',
            reader: {
                type: 'json',
                totalProperty: 'totalSize',
                successProperty: 'done',
                root: 'records'
            }  
       } 
    });
    solved the issue.

Thread Participants: 1

Tags for this Thread

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