View Full Version : Trouble with ScriptTagProxy/Store

18 Aug 2011, 1:52 AM
Hi guys.

I am trying to implement some simple Tweeter search using the already provided TwitterProxy (demos/twitter).

Ext.data.TwitterProxy = Ext.extend(Ext.data.ScriptTagProxy, {
//this is the url we always query when searching for tweets
url: 'http://search.twitter.com/search.json',
perPage: 50,
filterParam: undefined,

constructor: function(config) {
config = config || {};

Ext.applyIf(config, {
extraParams: {
suppress_response_codes: true

reader: {
type: 'json',
root: 'results'

Ext.data.TwitterProxy.superclass.constructor.call(this, config);

* We need to add a slight customization to buildRequest - we're just checking for a filter on the
* Operation and adding it to the request params/url, and setting the start/limit if paging
buildRequest: function(operation) {
var request = Ext.data.TwitterProxy.superclass.buildRequest.apply(this, arguments),
filter = operation.filters[0],
params = request.params;

Ext.apply(params, {
page: 1,
lang: "en",
result_type: "mixed",
rpp: 15

if (filter) {
Ext.apply(params, {
q: filter.value

//as we're modified the request params, we need to regenerate the url now
request.url = this.buildUrl(request);

return request;

Ext.data.ProxyMgr.registerType('twitter', Ext.data.TwitterProxy);

I have also defined a store:

app.stores.TwittsStore = new Ext.data.Store({
model: "Tweet"

and a model:

Ext.regModel("Tweet", {
fields: [
{name: "id", type: "int"},
{name: "text", type: "string"},
{name: "from_user", type: "string"},
{name: "profile_image_url", type: "string"}
proxy: 'twitter'

I create the list containing tweets in the following manner:

app.views.SomePanel.twittsList = new Ext.List({
id: "twittsList",
store: app.stores.TwittsStore,
emptyText: 'No tweets found',
disableSelection: true,
itemTpl: new Ext.XTemplate(
'<img src="{profile_image_url}" />',
'<div class="x-tweetanchor"></div>',
'<div class="tweet-bubble">',
'<div class="tweet-content">',
'<span class="posted">{created_at}</span>',
linkify: function(value) {
return value.replace(/(http:\/\/[^\s]*)/g, "<a target=\"_blank\" href=\"$1\">$1</a>");

I have a refresh button which does the following:


However, I always get the 'No tweets found' message in the list (the default text). I have checked and debugged the code a bit: the call to the tweeter search.json is made, the result is fetched correctly within the Ext.data.ScriptTagProxy.createRequestCallback method - the options variable.

What seems to be the problem here? Any ideas and suggestions are welcome.

Best regards,

18 Aug 2011, 4:24 AM
Nevermind that, I just forgot to set the remoteFilter property to true.