PDA

View Full Version : how can i change the url of a ajax proxy of a data.store dynamically



tianhao
15 Aug 2012, 11:55 PM
hi,
this is the code of a data store with ajax in a gridpanel:
xtype: 'gridpanel',
......
store: Ext.create('Ext.data.Store',{fields: [...],proxy: {type: 'ajax',url: 'duty.json.ajax.php',...}})
how can i change the url in web page
from 'duty.json.ajax.php' to a new one, like 'duty.json.ajax.php?id=5'
thanks.

Farish
16 Aug 2012, 12:02 AM
using the setProxy method of the store:

http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.Store-method-setProxy (http://docs.sencha.com/ext-js/4-0/#%21/api/Ext.data.Store-method-setProxy)

You can specify the new url in setProxy. e.g.


store.setProxy({
type: 'ajax',
url: 'newURL',
reader: { type: 'json' },
writer: { type: 'json'}
});

tianhao
16 Aug 2012, 12:19 AM
thank you very much