PDA

View Full Version : Writing custom writers in 3.1



zefciu
29 Dec 2009, 6:16 AM
Hello. I have noticed an undocumented serious change in DataWriter. The render method no longer accepts 'action' as its argument. This change caused a serious failure of my custom writer which rendered the POST args differently depending on the action. My question is: can I still check what action is performed from my writer, or should I rewrite its logic?

This is the code of my writer that worked so far:


Ext.em.cake.CakeWriter = Ext.extend(Ext.data.DataWriter, {
render : function (action, rs, params, data) {
var root, d;
root = this.meta.root;
if (action === 'create' || action === 'update') {
for (d in rs[root]) {
params['data' + this.parseDots(d)] = rs[root][d];
}
} else if (action === 'destroy') {
params['data[id]'] = data;
}
},
createRecord : function (rec) {
return this.toHash(rec);
},
updateRecord : function (rec) {
return this.toHash(rec);
},
destroyRecord : function (rec) {
return rec.id;
},
writeAllFields: true,
parseDots : function (value) {
return '[' + value.replace('.', '][') + ']';
},
initComponent: function () {
Ext.em.cake.CakeWriter.superclass.initComponent.call(this);
}
});