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

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