I have the following code. I’d like to make the proxy’s type and url properties dynamic based on if url.local or url.remote is chosen.
var url = {
local: './grid-filtering/sample.json', // static data file
remote: '/Customer/Get'
};
Ext.require('sbpm.model.Product');
Ext.define('sbpm.store.Customer', {
extend: 'Ext.data.JsonStore',
constructor: function (cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
// store configs
autoDestroy: true,
storeId: 'Customer',
model: 'sbpm.model.Product',
proxy: {
type: 'jsonp',
url: url.local,
reader: {
root: 'data',
totalProperty: 'total'
}
},
remoteSort: false,
sorters: [{
property: 'company',
direction: 'ASC'
}],
pageSize: 50
}), cfg]);
}
});
In other words, what I’d like to do is specify(in pseudocode):
if (url.local)
{
proxy:{
type: 'jsonp'
url: url.local,
// etc
}
}
else if (url.remote)
{
proxy:{
type: 'rest'
url: url.remote,
// etc
}
}
I’m sorry but I don’t know what kind of context to add to further explain the scenario, or if stackoverflow just uses some kind of text/code ratio to measure that, which would be annoying seeing that I’ve already explained the scenario very concisely and people can ask more detailed questions if they don’t understand it.
AbstractStoreclass has two methodssetProxy()/getProxy(). You can use them to switch proxies on-the-fly. If you need something more – like having two different proxies inside and switch between them without re-creating – you might need to extend existing classes.