PDA

View Full Version : TreePanel with cross domain data



m-kay
24 Oct 2012, 11:28 PM
Is it possible to load data for a treepanel from a cross domain source?

I tried to use a ScriptTagProxy inside my TreeLoader but I can't get it working. Any suggestions?

Thanks for you help

m-kay
25 Oct 2012, 11:36 PM
I managed to do it with a JsonStore and ScriptTagProxy inside the directFn function. However I don't know if this is a good solution or if the is a better or even simpler way to do it.



new Ext.tree.TreeLoader({
directFn:function(nodeId, callback ){
var store = new Ext.data.JsonStore({
root: 'folders',
totalProperty:"results",
idProperty: 'id',
remoteSort: true,
autoLoad: false,


fields: [
'id', 'name', 'text', 'type'
],


proxy: new Ext.data.ScriptTagProxy({
url: 'http://someurl.ch/data/test.php'
})
});

store.load({
callback: function(){
var response = [];
for(i=0;i<store.data.items.length;i++){
response.push(store.data.items[i].data);
}

console.log(response);

callback(response, {status:true});
},
params: {folder:nodeId}
});
}
})

wm003
4 Jan 2013, 1:41 PM
Thats the only way to do it , afaik.