PDA

View Full Version : hasMany and Writer



Cedric_
4 Jan 2012, 9:27 AM
Hi,

i have some serious problems regarding a Model which has a haveMany Relation and the Writer of this Model. Everything works fine in the UI itself, but i can't get the Writer to Post the changed Data. In fact i am having two Problems:

Let's say that i have two Models #A# and #B# - #A# hasMany of #B#. #A# has AutoSync true and #B# stores it's Data in Memory and has no configured Reader or Writer. My Problems are:

a) When i change Data directly in #A# everything works fine and Ext posts the Changes BUT only the Data of #A# and not a single Record of #B# which belongs to it.
b) When i change Data in #B# of a given #A# nothing get's posted, and the Writer behaves as if no changes happened.

I tried to fix this with sync() and setDirty() without any Luck. So there are two Questions:

a) how can i get the Writer of #A# to Post the Data of the hasMany-Relation #B# when it get's synced
b) how can i get the Writer of #A# to Post Data when i change something in the hasMany-Relation #B#

any hints or help would be nice, i am really stuck on this!

Cedric_

mitchellsimoens
4 Jan 2012, 10:46 AM
Just to let you know I moved this from the Core to the Q&A forum.

Cedric_
5 Jan 2012, 4:17 AM
Problem a) has been solved with a custom Writer:

Ext.define('custom.writer.Json', {
extend: 'Ext.data.writer.Json',
getRecordData: function(record) {
Ext.apply(record.data,record.getAssociatedData());
return record.data;
}
});