0
votes
Ext.define('apikeygen.store.Clients', {

extend: 'Ext.data.Store',

alias: 'store.Clients',

requires: ['CCC.model.Client',
           'CCC.util.ActorContext'],

storeId: 'ClientsStore',

model: 'CCC.model.Client',

proxy: {
    type: 'ajax',
    url: '/services/clients',

    reader: {
        type: 'json',
        root: 'clients.client'
    }
    extraParams : {
       token : dynamica value ----------------> How to set this value dynamically
    }


}

});

I have a store like the above in Extjs . How to set the token value dynamically ?

i have the "token" value in Context i can access that value like : ActorContext.getToken();

how to assign that ActorContext.getToken(); to "token" param in Extjs store.

3

3 Answers

1
votes

First, the store should be configured with autoLoad:false because you do not want it to load early in the application initialization phase, but only after the token is available.

Then, when you are ready to load the store (token is available) call:

store.getProxy().setExtraParam('token', ActorContext.getToken());
store.load();
0
votes

Can't you just assign the value ?

var store = Ext.create('apikeygen.store.Clients');
store.proxy.extraParams.token = ActorContext.getToken();
store.load();
0
votes

add this in CONTROLLER, or VIEW inside initComponent

var store = Ext.create('apikeygen.store.Clients',{
   storeId: 'storeClients',
});
store.proxy.extraParams = { token: 'your data value'};

and load your store like this :

store.load()