In Extjs4.1, how to add additional params before one store sync?
Asked Answered
S

3

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?

Skirl answered 8/6, 2013 at 10:9 Comment(4)
Are you using autosync? Are the extra params you need to pass dynamic?Hamlett
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? @AmitAvivSkirl
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.Hamlett
Or just set it before the sync, write your own sync function, that fetches the extra params, sets them, and do sync.Hamlett
A
2

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

Accustom answered 10/2, 2015 at 17:29 Comment(1)
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.Nealon
G
1

Use

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

Gonsalve answered 30/11, 2015 at 18:6 Comment(0)
C
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");
Chimborazo answered 18/2, 2016 at 3:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.