Hello, I'd like to report I've been dealing with since version 5.0 but now I finally took the time to report, with a suggestion about a possible 5.1-compatible initial implementation of fix.

In my application I have several models that use reference fields to other models. In a lot of these cases, my server already replies the data of these references expanded to client, like example below:



Code:



{
id: 1,
first: 'Bob',
parent: {
id: 10,
first: 'Dan'
}
}

This mostly works as store reader is able to read the data of field, however it doesn't configure the model in same way it would configure if this reference was set in client. I've created a fiddle linked below as example and explaining better the differences:

http://ift.tt/1wAfBpW


The fix I've implemented in my application code is something like below, which probably needs to be improved to use a strategy that cares about configured name of id property of model:



Code:



var original = Ext.data.schema.ManyToOne.prototype.Right.prototype.read;
Ext.override(Ext.data.schema.ManyToOne.prototype.Right.prototype, {
read: function(leftRecord, node, fromReader, readOptions) {
// This must be done before following call as original data from request is lost after it.
var isAssociatedDataExpanded = Ext.isObject(leftRecord.data[this.role]);


var result = original.call(this, leftRecord, node, fromReader, readOptions);


if (isAssociatedDataExpanded) {
var association = leftRecord.associations[this.role];
var getterName = association.getterName;
leftRecord.data[this.role] = leftRecord[getterName]().id;
}


return result;
}
});