Success! Looks like we've fixed this one. According to our records the fix was applied for TOUCH-1153 in a recent build.
  1. #1
    Sencha User cyberwombat's Avatar
    Join Date
    Oct 2011
    Posts
    237
    Vote Rating
    2
    cyberwombat is on a distinguished road

      0  

    Default DataView.prepareAssociatedData does not handle belongsTo associations

    DataView.prepareAssociatedData does not handle belongsTo associations


    REQUIRED INFORMATIONExt version tested:
    • Sencha Touch 2 PR2
    Browser versions tested against:
    • Chrome 11
    DOCTYPE tested against:
    • HTML
    Description:
    • The DataView.prepareAssociatedData does not handle loading of belongsTo associations.
    Steps to reproduce the problem:
    • Please view http://www.sencha.com/forum/showthre...iations-in-tpl for a full example and description of issue. There is also a semi working method extension listed. That example has Messages with Users. Each message has one user. I load the messages nested with their user in json and want to display the messages as a list with the user data.
    The result that was expected:
    • In my tpl I expected to be able to write {user.name} and have their name show.
    The result that occurs instead:
    • blank name.
    Test Case:
    http://www.sencha.com/forum/showthre...iations-in-tpl has all the code. If the prepareAssociatedData I have in my list is not there it will not work.

    Possible fix:
    • I modified the prepareAssociatedData method based on another posters fix for ST1. From the comments in the method I assume there are other issues which I have yet to encounter. I am not sure if those issues still hold true for ST2 or not as I was not the one to add the comment.
    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,
                    associatedStore, associatedRecords, associatedRecord,
                    associatedRecordCount, association, internalId;
    
    
                for (; i < associationCount; i++) {
                    association = associations[i];
                    if(association.type === 'belongsTo') {
                        associatedRecord = record[association.associatedName + 'BelongsToInstance'];
                        if(associatedRecord) {
    //console.log(SquareRoute.lib.Util.dump(associatedRecord.data));
                            associationData[association.name] = associatedRecord.data;
                            /*
                            * This does not function as intended. When uncommented items which the record
                            * has many of will only have one item in the result set. However, for now I am
                            * not going to worry about it. Though, I am pretty sure it is important that
                            * this functions properly considering if the record here had yet another
                            * association it would not be loaded into the template. Essentially, at this time
                            * all belongTo associations can be considered leafs, sadly.
                            */
                            //Ext.apply(associationData[association.name], this.prepareAssociatedData(associatedRecord, ids));
                        }
                    } else {
                        //this is the hasMany store filled with the associated data
                        associatedStore = 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 (associatedStore && associatedStore.data.length > 0) {
                            associatedRecords = associatedStore.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));
                                }
                            }
                        }
                    }
                }
    
    
                return associationData;
            },

  2. #2
    Sencha - Sencha Touch Dev Team Jamie Avins's Avatar
    Join Date
    Mar 2007
    Location
    Redwood City, California
    Posts
    3,661
    Vote Rating
    19
    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 for the report.

    Sencha Inc

    Jamie Avins

    @jamieavins

  3. #3
    Sencha User
    Join Date
    Mar 2007
    Location
    Haarlem, Netherlands
    Posts
    1,243
    Vote Rating
    8
    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 report.

Thread Participants: 2

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar