View Full Version : Nested data and create operation

27 Jul 2012, 3:19 AM

I have set up a nested data scenario using the hasMany relationship. This works as expected for read operations, the read record contains a custom store which I can use to access the nested data.

Also, when you perform a create operation against a remote server you normally can perform additions or modifications to the new record, such a database generated id, server initialization of some default fields, etc.

However, I would like to combine both features: on creation-time I'd like the server to provide some default nested data. This doesn't seem to work for me, the server POST response contains nested data, the returned not-nested data produces changes to the model, but the nested store is empty.

Is this supposed to work and I am doing something wrong?

If this feature is not provided by extjs, what could be a good workaround?

Thanks in advance,


27 Jul 2012, 5:18 AM
copyFrom: function(sourceRecord) {
var me = this;
if (sourceRecord) {
sourceRecord.associations.each(function(association) {
if (association.storeName) {
me[association.storeName] = sourceRecord[association.storeName];

After each request data proxy reads records and it does it right - reads model associated data as well as model fields data. Then it tries to syncronize clientside copy of the record with server side copy of the record returned by server and parsed by reader. So that syncronization is a bit buggy, ehm.
Check Ext.data.proxy.Server.prototype.processResponse and Ext.data.Operation.prototype.commitRecords for more details.

30 Jul 2012, 12:18 PM
That was really useful, thanks for the pointers!