PDA

View Full Version : ScriptTagProxy setUrl



lfs2008
25 Apr 2011, 6:54 AM
Hi all!

I have DataView with extjs Twiter posts and it works fine

What is the best way to reload ScriptTagProxy with URl for example

http://search.twitter.com/search.json?q=extjs4

There is no setUrl method..
thanks


App.Twitterpanel = new Ext.DataView({



store : new Ext.data.JsonStore({

proxy : new Ext.data.ScriptTagProxy({
url : http://search.twitter.com/search.json?q=extjs
}),
fields : [
{
name : 'text',
mapping : 'text'
},
{
name : 'image',
mapping : 'profile_image_url'
},
{
name : 'created_at',
mapping : 'created_at',
type: 'date',
renderer: Ext.util.Format.dateRenderer('m/d/Y h:ia')
},
{
name : 'user',
mapping : 'from_user'
}
],
baseParams : {
rpp : 10
},
root : 'results',
autoLoad : true
}),


autoScroll : true,
tpl : new Ext.XTemplate(
'',
'<tpl for=".">',
'',
'<p><img class="profile-image" src="{image}" /></p>',
'<p><a href="http://twitter.com/#!/{user}">{user}</a></p>',
'<p>{created_at}</a></p>',
'<p>{text}</p>',
'<hr />',
'</tpl>',
'>'
),


emptyText : 'No tweets to display'

});

hiphopanonymous
8 Mar 2017, 10:32 AM
I recently ran across the same issue. What solved it for me was setting the ScriptTagProxy URL to the new desired URL and then setting the API to null. The next time the proxy ran through doRequest and hit this.buildUrl(action, res), the new URL was used. You could also make your own setUrl function for ScriptTagProxy like below.



Ext.extend(Ext.data.ScriptTagProxy, Ext.data.DataProxy, {

/**
* Used for overriding the url used for a single request. Designed to be called during a beforeaction event to override the url previously set
* via an api configuration parameter.
* @param {String} url
*/

setUrl : function(url) {
this.url = url;
this.setApi(null);
}


Then you can use proxy.setUrl('someUrl') in your beforeload listener.