View Full Version : Sending extra parameters when saving a model instance (on record.save())

18 Nov 2011, 3:14 AM
Hi there.
I need to send some extra parameters to the server when updating/creating a record/model, but can't figure out how. Something like this:

// Show form etc..
var form = new Ext.form.Panel();
var record = new Model();

Then when some imaginary button is clicked

var record = form.getRecord();

extraParams : { // this is what i want to do, to send additional parameters
param1 : 'some value',
param2 : 'some other value'
success : function(record) {
// all good

I've searched the forums and api, but only way i've managed to do it is to add extra fields to my model, which I don't want, since its used elsewhere.

18 Nov 2011, 5:42 AM
edit: just took a look at the sources. try out


18 Nov 2011, 8:06 AM
in my case it will not work...

21 Nov 2011, 12:31 AM

This kindof does the job, but the params are always added to the querystring even though request method is not GET.
In my scenario i'm using a RESTful store, so it would be nice if params added could be sent in the same manner default params are (GET, POST, PUT, DELETE)

21 Nov 2011, 1:29 AM
if you like to, i can move the topic to the bugreport forums.

21 Nov 2011, 11:40 AM
You could do that, even though i'm not so sure its a bug, but rather limitations of the current http-protocol - especially in terms of the DELETE request where its not safe to send a body with the request: (http://stackoverflow.com/questions/299628/is-an-entity-body-allowed-for-an-http-delete-request)
It would still be nice to hear what the developers has to say on the topic.

Essentially, what i need to do is to send some meta information when i update or delete a model instance. For example i want the end user to specify a reason for deleting. For now i've reverted to doing a form post and manually reloading the store at need. Kind of hackish. Thanks for your input though!

21 Nov 2011, 10:57 PM
i overwrite writeRecords to have the functionality:

writeRecords: function(request, data) {
var root = this.root;

Ext.applyIf(data[0], request.params || {});

if (this.allowSingle && data.length == 1) {
// convert to single object format
data = data[0];

if (this.encode) {
if (root) {
// sending as a param, need to encode
request.params[root] = Ext.encode(data);
} else {
Ext.Error.raise('Must specify a root when using encode');
} else {
// send as jsonData
request.jsonData = request.jsonData || {};
if (root) {
request.jsonData[root] = data;
} else {
request.jsonData = data;
return request;

23 Nov 2011, 4:09 AM
I tested your override, but it still just gets appended to the querystring (as in GET).

23 Nov 2011, 11:36 AM
Did you use extraParams or params? When using my override you must use it like:


30 Nov 2011, 5:10 AM
I use params as specified, but its always appended to querystring regardless of http method