Due to the impact related to this issue, we have to defer this issue to the next major or minor release.
-
Sencha User
Ext.dataview.DataView prepareAssociatedData does not reset index variable j
The prepareAssociatedData in the dataview prepares the records for rendering the template. If you have more than one association not all referenced records will be converted, because the index variable j used in the inner loop is not reset to zero. You have to add the highlighted statement to preperly iterate over every associated record even if you have more than one association.
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];
//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
// FIX: j = 0
for (j = 0; 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;
}