View Full Version : How to pass a parameter to each batch request when using store.sync()

11 Dec 2012, 10:30 AM

I would like to pass some parameters while using store.sync() in batch mode using the "options" parameter of sync method. I would like to use these parameters in the events of Ajax proxy (beforerequest, requestcomplete, requestexception).

I've debugged the source code and found that these options are not passed to each Ajax request (created for each item in batch). So they don't exist in the options parameter of the listed events. Only the batch property (if exists) in options is passed to the request. I've listed the code that handles this process:

if (options.batch) {
if (Ext.isDefined(options.batch.runOperation)) {
batch = Ext.applyIf(options.batch, {
proxy: me,
listeners: {}
} else {
options.batch = {
proxy: me,
listeners: options.listeners || {}

if (!batch) {
batch = new Ext.data.Batch(options.batch);

So I thought instead of putting my parameters directly inside an object I should put them in an object under a batch property by creating a batch like this:

var options = {
batch: new Ext.data.Batch({
paramName: paramValue

But then I realized that batch isn't also carried to options.

Is there a way to do this? If not don't you think there should be? Even batch calls need some extra parameter to be propagated in each step.

Thanks in advance


13 Dec 2012, 7:08 AM
So you want the request to have extra params or each object in the array to have extra params?

14 Dec 2012, 2:46 AM
Yes. When we use batch, ajax request is created for each operation automatically. But we lose the control of passing any extra parameter. It takes the url, prepares the fields and sends the request without allowing us to send any extra parameter. I could use this parameter on the server side or on the client side after response is received.

1 Nov 2013, 10:39 AM
//the code below allows me to send extraParams to my .Net mvc crud (add) method
var rec;
rec = Ext.create('SDR.model.wellreports.WellInfoModel',
Deleted: false,
Confidential: false,
LastSavedBy: window.currentUserId,
DrilledByOwner: false,
PaperSubmitted: false,
PluggedWithin48: false,
Migrated: false,
Comments: 'test by dev'

var store;
store = Ext.create('Ext.data.Store', {
model: 'SDR.model.wellreports.WellInfoModel'
var pxy;
pxy = wellInfoStore.getProxy();
pxy.setExtraParam('Deleted', false);
pxy.setExtraParam('Confidential', false);
pxy.setExtraParam('LastSavedBy', window.currentUserId);
pxy.setExtraParam('DrilledByOwner', false);
pxy.setExtraParam('PaperSubmitted', false);
pxy.setExtraParam('PluggedWithin48', false);
pxy.setExtraParam('Migrated', false);
pxy.setExtraParam('Comments', 'test by dev');