PDA

View Full Version : Change Store Proxy URL without Creating New Store



rkdeiss
12 Apr 2010, 12:45 PM
I want to be able the change a store's proxy url without recreating the store. Originally I created a new store each time and that worked fine:


function PluginStore(url, isNew)
{
var PluginFieldDefinitions =
[{name:'type',mapping:'@type'},
{name:'algid',mapping:'@algid'},
'key',
'instance',
'description',
'add',
{name:'logging_level',type:'int'}];

DATA.pluginRecord = Ext.data.Record.create(PluginFieldDefinitions);

var xmlreader = new
Ext.data.XmlReader({record: 'alg'}, DATA.pluginRecord);

var ds = new Ext.data.Store
({
proxy: new Ext.data.HttpProxy({url: url}),
reader: xmlreader
});

...

ds.load();

ds.on('load', function()
{
...
}

...
}

Then I tried to change just the URL:


function PluginStore(url, isNew)
{
if (DATA.pluginStore == undefined)
{
var PluginFieldDefinitions =
[{name:'type',mapping:'@type'},
{name:'algid',mapping:'@algid'},
'key',
'instance',
'description',
'add',
{name:'logging_level',type:'int'}];

DATA.pluginRecord = Ext.data.Record.create(PluginFieldDefinitions);

DATA.pluginXmlReader = new
Ext.data.XmlReader({record: 'alg'}, DATA.pluginRecord);

DATA.pluginStore = new Ext.data.Store
({
proxy: new Ext.data.HttpProxy({url: url}),
reader: DATA.pluginXmlReader
});
}
else
{
DATA.pluginStore.proxy.url = url;
}

...

DATA.pluginStore.load();

DATA.pluginStore.on('load', function()
{
...
}

...
}

When I looked at the value for the URL in Firebug, it appeared to change, but what was read was the original URL from when the store was created. Any ideas?

rkdeiss
13 Apr 2010, 11:16 AM
Found solution in "dynamicaly change store url" thread.