7

In store, there is an event beforeload:

beforeload( Ext.data.Store store, Ext.data.Operation operation, Object eOpts )

by listening to this event, i can add my additional param to operation when i do query action, like this:

store.on('beforeload', function(store, operation) {
    operation.params = Ext.applyIf({
        myParam1: 'param1',
        myParam2: 'param2'
    }, operation.params);
});

i also need add my additional params when i do create, update and destroy action. However, the sync event do not pass the operation or store:

beforesync( Object options, Object eOpts )

is there any other way?

txx
  • 81
  • 1
  • 4
  • Are you using autosync? Are the extra params you need to pass dynamic? – Amit Aviv Jun 08 '13 at 10:24
  • i call store.sync() instead of using autoSync. Does it means i must change extra params every time before i do query or CDU action? @AmitAviv – txx Jun 08 '13 at 10:33
  • 2
    Depending on the context of what actually causes the change in the extra params, you may want to use `setExtraParam` when the change occur in the UI. Say there is a checkbox somewhere that is causing the change, you may listen to the change event, and set the extraParam there. – Amit Aviv Jun 08 '13 at 10:38
  • 1
    Or just set it before the sync, write your own sync function, that fetches the extra params, sets them, and do sync. – Amit Aviv Jun 08 '13 at 10:42

3 Answers3

2

Use store.getProxy().setExtraParams({ param: 'value', so:'on' }); hope will work fine :D

  • the problem is that the extraParams is only sent on 'read' requests not on create, update, destroy requests if you are defining an API on the store. – code4jhon Jan 17 '16 at 21:27
1

Use

store.getProxy().extraParams.paramName1= paramValue1; store.getProxy().extraParams.paramName2= paramValue2;

Harshal
  • 961
  • 1
  • 11
  • 26
0

ExtraParam will only take effect when call the read api. Not work for create, update, delete

grid.store.getProxy().setExtraParam('paramA','XXX'); 

I try another way.

grid.store.proxy.api.update = url + "?paramA=XXX"; //set before call sync()

Java can get the param by

request.getParameter("paramA");
cassie
  • 1