View Full Version : baseParams to be used only for loading records, not for updating them

23 Oct 2009, 2:06 AM
Is it possible to set baseParams on store, but to be used only at reads (store load) not at writes (record updates)?
The case is following:
I have an EditorGrid which displays records with tasks, and some filter applied to it. In the filter I can select checkbox to display only tasks with status "New" or "Reopened" - it works by setting something like this:

store.baseParams = {status: ['new','reopened']}on the grid.
But now, when user edits any record (say he changes the task description), then the update request goes to server sending new description value, but unfortunetely the request sends also those two values from base params:

description = 'blah'
status = 'new'
status = 'reopened'and server throws exception like "can't assign list ['new', 'reopened'] to the field 'status' (which is String)".
I thought that I could apply baseParams to the api object, instead of applying it to the store directly:

store.proxy.api['read'] = {baseParams: ...}But it doesn't work.
Any hint how to set baseParams to be used only for loading, and not for updating records?

23 Oct 2009, 4:29 AM
You may want to try using params rather than baseParams. This is what the API docs say about baseParams:

baseParams : Object
An object containing properties which are to be sent as parameters for every HTTP request.
Parameters are encoded as standard HTTP parameters using Ext.urlEncode.
Note: baseParams may be superseded by any params specified in a load request, see load for more details.
This property may be modified after creation using the setBaseParam method.

23 Oct 2009, 4:33 AM
How to make them "persistent"? I mean: if the grid is paged, after going to the second page i'd like to have those params still applied - if I remember correctly, baseParams are used for this purpose...

23 Oct 2009, 4:39 AM
In your update function, try setting the baseParams to = ''. Then after the update, set them back to what they were before.

23 Oct 2009, 5:45 AM
Yes, that's another solution, but personally I don't like it - it looks too much like a hack to me. In the meantime I've come up with this override, it seems to work for me and allows for specifying baseParams on api object :

Ext.override(Ext.data.HttpProxy, {
//override doRequest to allow for specifying baseParams on api object (for selected methods)
doRequest : function(action, rs, params, reader, cb, scope, arg) {
var o = {
method: (this.api[action]) ? this.api[action]['method'] : undefined,
request: {
callback : cb,
scope : scope,
arg : arg
reader: reader,
callback : this.createCallback(action, rs),
scope: this
// Sample the request data: If it's an object, then it hasn't been json-encoded yet.
// Transmit data using jsonData config of Ext.Ajax.request
if (typeof(params[reader.meta.root]) === 'object') {
o.jsonData = params;
} else {
o.params = params || {};
//allow for baseParams applied to selected method
if (this.api[action] && this.api[action].baseParams) {
o.params = Ext.apply(params, this.api.read.baseParams);
// Set the connection url. If this.conn.url is not null here,
// the user may have overridden the url during a beforeaction event-handler.
// this.conn.url is nullified after each request.
if (this.conn.url === null) {
this.conn.url = this.buildUrl(action, rs);
else if (this.restful === true && rs instanceof Ext.data.Record && !rs.phantom) {
this.conn.url += '/' + rs.id;

Ext.applyIf(o, this.conn);

// If a currently running request is found for this action, abort it.
if (this.activeRequest[action]) {
// Disabled aborting activeRequest while implementing REST. activeRequest[action] will have to become an array
this.activeRequest[action] = Ext.Ajax.request(o);
// request is sent, nullify the connection url in preparation for the next request
this.conn.url = null;

25 Oct 2009, 2:38 PM
After longer analysis, I think I will use GridFilters addon (http://www.extjs.com/deploy/dev/examples/grid-filtering/grid-filter-local.html) instead of home-grown filtering solution. Than I don't have to worry about baseparams etc.