How to change / add parameters to the repository

On sencha-touch, here 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 to change the settings? I tried

 params:{ format: 'json'} 

But its not working!

+7
source share
4 answers

Store Announcement

 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 parameters to the proxy server and reading ajax repository

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

Hope this helps.

+11
source

To dynamically set additional parameters:

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

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

If you want to set several parameters at once, you can use the following

 proxy.setExtraParams({ 'param1':'value 1', 'param2':'value 2' }); 
+3
source

You can try using extraParams :

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

I offer you a more elegant solution, Sencha's way of doing this:

 //Take your store var store = Ext.StoreMgr.get('YOUR_STORE_ID'); //Apply the params Ext.apply(store.getProxy().extraParams, { partyID: options.partyID, eventName: options.eventName }); //Reload your store store.contactInfoId.read(); 

Hope this helps.

+1
source

All Articles