Success! Looks like we've fixed this one. According to our records the fix was applied for TOUCH-904 in a recent build.
  1. #1
    Ext JS Premium Member
    Join Date
    Jul 2008
    Location
    Miami, FL
    Posts
    56
    Vote Rating
    1
    omarc is on a distinguished road

      0  

    Default DataView with hasOne association

    DataView with hasOne association


    I am trying to use a DataView with a template that makes reference to a hasOne association and I get the following error in Safari:

    TypeError: '[object Object]' is not a function (evaluating 'Ext.log('Error: ' + e.message)')

    After tracing the problem, I found that the prepareAssociatedData function in DataView.js only supports hasMany associations, I modified it so that it also works for hasOne associations:

    Code:
            prepareAssociatedData: function(record, ids) {
                //we keep track of all of the internalIds of the models that we have loaded so far in here
                ids = ids || [];
    
    
                var associations     = record.associations.items,
                    associationCount = associations.length,
                    associationData  = {},
                    i = 0,
                    j = 0,
                    associatedInstance, associatedRecords, associatedRecord,
                    associatedRecordCount, association, internalId;
    
    
                for (; i < associationCount; i++) {
                    association = associations[i];
    
    
                    if (association.type == "hasMany") {
                        //this is the hasMany store filled with the associated data
                        associatedInstance = record[association.storeName];
    
    
                        //we will use this to contain each associated record's data
                        associationData[association.name] = [];
    
    
                        //if it's loaded, put it into the association data
                        if (associatedInstance && associatedInstance.data.length > 0) {
                            associatedRecords = associatedInstance.data.items;
                            associatedRecordCount = associatedRecords.length;
    
    
                            //now we're finally iterating over the records in the association. We do this recursively
                            for (; j < associatedRecordCount; j++) {
                                associatedRecord = associatedRecords[j];
                                internalId = associatedRecord.internalId;
    
    
                                //when we load the associations for a specific model instance we add it to the set of loaded ids so that
                                //we don't load it twice. If we don't do this, we can fall into endless recursive loading failures.
                                if (ids.indexOf(internalId) == -1) {
                                    ids.push(internalId);
    
    
                                    associationData[association.name][j] = associatedRecord.data;
                                    Ext.apply(associationData[association.name][j], this.prepareAssociatedData(associatedRecord, ids));
                                }
                            }
                        }
                    } else if (association.type == "hasOne") {
                        //this is the to-one record instance
                        associatedInstance = record[association.instanceName];
    
    
                        //if it's loaded, put it into the association data
                        if (associatedInstance) {
                            associationData[association.name] = associatedInstance.data;
                            Ext.apply(associationData[association.name], this.prepareAssociatedData(associatedInstance, ids));
                        }
                    }
                }
    
    
                return associationData;
            }
    Hope this or some variation makes it into the final release.

    Thanks and great work on Sencha Touch!

    Omar

  2. #2
    Sencha - Sencha Touch Dev Team Jamie Avins's Avatar
    Join Date
    Mar 2007
    Location
    Redwood City, California
    Posts
    3,661
    Vote Rating
    20
    Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough

      0  

    Default


    Thank you, we'll be sure to resolve that.

  3. #3
    Sencha User
    Join Date
    Sep 2011
    Posts
    125
    Vote Rating
    0
    oddz is on a distinguished road

      0  

    Default


    Doesn't pass belongsTo either. Though that feature did not exist in 1.0 either… had to add support myself.

  4. #4
    Sencha User
    Join Date
    Mar 2007
    Location
    Haarlem, Netherlands
    Posts
    1,243
    Vote Rating
    10
    TommyMaintz will become famous soon enough TommyMaintz will become famous soon enough

      0  

    Default


    This has been fixed and will be part of the next Touch 2.0 release. Thanks for the port and debugging done to solve this!

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