Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change/add params on a store

On a sencha-touch, here's is my store declaration

Ext.regStore('newsStore',  {
    model: 'News',
    autoLoad: true,
    proxy: {
        type: 'ajax',
        url: '../news/list.form?format=json',
        reader: {
            type: 'json',
            root: ''
        }
    },                        
});

How can I modify params? I tried

params:{ format: 'json'}

But its doesn't work!

like image 718
BasicCoder Avatar asked May 25 '11 07:05

BasicCoder


2 Answers

Store declaration

new Ext.data.Store({
model:'prj.models.ContactInfo',
storeId:'contactInfoId',
proxy:{
    type:'ajax',
    url:'/GetContactInfoByID',
    reader:{
        type:'json'
    },
    extraParams:{
        format:'json'
    },
    listeners:{
        exception:function(proxy, response, orientation){
            console.error('Failure Notification', response.responseText);
            Ext.Msg.alert('Loading failed', response.statusText);
        }
    }
}   
});

Adding params to proxy and read ajax store

prj.stores.contactInfoId.getProxy().extraParams.partyID = options.partyID;
prj.stores.contactInfoId.getProxy().extraParams.eventName = options.eventName;
prj.stores.contactInfoId.read();

Hope this helps.

like image 198
mehul9595 Avatar answered Sep 24 '22 00:09

mehul9595


For dynamically setting extra parameters:

If you want to set single parameter at a time, you can use following

var proxy= myStore.getProxy();
proxy.setExtraParam('param1', 'value 1' );
proxy.setExtraParam('param2' , 'value 2' );
myStore.load();

If you want to set multiple parameters at a time, you can use following

proxy.setExtraParams({
     'param1':'value 1',
     'param2':'value 2'
});
like image 32
Hemant G Avatar answered Sep 23 '22 00:09

Hemant G