kesteb
12 Mar 2010, 10:54 AM
I haven't seen anything like this yet, which surprised me. Here is a simple DataWriter for those who want to have their parameters in HTTP POST fashion, instead of a glob of JSON or XML. It works for me, use at your own risk.
/*
* File: Ext.ux.data.HttpWriter.js
* Date: 11-Mar-2010
* By : Kevin Esteb
*
* A DataWriter that renders the parameters in standard HTTP POST fashion.
*
* kesteb(at)wsipc.org
*
* Use and abuse as you see fit, but please leave this attribution.
* Thank you.
*
*/
Ext.namespace('Ext.ux.data');
Ext.ux.data.HttpWriter = Ext.extend(Ext.data.DataWriter, {
constructor: function(config) {
Ext.ux.data.HttpWriter.superclass.constructor.call(this, config);
},
render: function(params, baseParams, data) {
Ext.apply(params, baseParams);
for (var x in data) {
params[x] = data[x];
}
},
createRecord: function(rec) {
return this.toHash(rec);
},
updateRecord: function(rec) {
return this.toHash(rec);
},
destroyRecord: function(rec) {
var data = {};
data[this.meta.idProperty] = rec.id;
return data;
}
});
/*
* File: Ext.ux.data.HttpWriter.js
* Date: 11-Mar-2010
* By : Kevin Esteb
*
* A DataWriter that renders the parameters in standard HTTP POST fashion.
*
* kesteb(at)wsipc.org
*
* Use and abuse as you see fit, but please leave this attribution.
* Thank you.
*
*/
Ext.namespace('Ext.ux.data');
Ext.ux.data.HttpWriter = Ext.extend(Ext.data.DataWriter, {
constructor: function(config) {
Ext.ux.data.HttpWriter.superclass.constructor.call(this, config);
},
render: function(params, baseParams, data) {
Ext.apply(params, baseParams);
for (var x in data) {
params[x] = data[x];
}
},
createRecord: function(rec) {
return this.toHash(rec);
},
updateRecord: function(rec) {
return this.toHash(rec);
},
destroyRecord: function(rec) {
var data = {};
data[this.meta.idProperty] = rec.id;
return data;
}
});