PDA

View Full Version : Store error on load



mitchellsimoens
17 Jul 2010, 6:04 PM
I'm trying to start simple and build from there but for the life of me I cannot figure out what is going wrong. I have a simple JsonStore with minimal config options:


new Ext.data.JsonStore({
data: [
["Dept A"],
["Dept B"]
],
fields: ["name"]
}

but I keep getting this error:


Uncaught TypeError: Cannot call method 'indexOf' of undefined

ext-touch-debug.js line 289

which is where it deals with the 'url' option. Any ideas why?

evant
18 Jul 2010, 4:21 PM
In that case you'd want to attach an array reader, or modify your data:



Ext.setup({
tabletStartupScreen: 'tablet_startup.png',
phoneStartupScreen: 'phone_startup.png',
icon: 'icon.png',
glossOnIcon: false,

onReady: function() {
var s = new Ext.data.JsonStore({
data: [{
name: 'Dept A'
},{
name: 'Dept B'
}],
fields: ['name']
});
alert(s.getCount());
}
});

elishnevsky
20 Jul 2010, 11:51 AM
Loading JsonStore remotely seems to be broken badly. No matter what I do I keep getting different errors. Tried everything, from specifying url config to manually defining proxy and reader. With url config on the JsonStore, it doesn't even make a call to the server. With manually configured proxy it goes to the server, but breaks somewhere after that trying to display the data. Triple-checked the model and data.

danvega
20 Jul 2010, 2:51 PM
Eugene..

I would check out the docs.. I am pretty sure that if you need data remotely you need to use a script tag proxy. By default the JSON store uses a JSON Proxy. This is the the twitter example that shows using a scriptTagProxy



store: new Ext.data.Store({
autoLoad: true,
model: "Tweet",
proxy: {
type: 'scripttag',
url: 'http://search.twitter.com/search.json',
extraParams: {
q: 'Cleveland',
rpp: 50,
suppress_response_codes: true
},
reader: {
type: 'json',
root: 'results'
}
}
})

elishnevsky
20 Jul 2010, 5:04 PM
No, ScriptTagProxy must be used only to retrieve data from a domain other than the domain from which the running page is served. I need to processes data requests within the same domain, that is what AjaxProxy (former HttpProxy) is for.

danvega
20 Jul 2010, 5:05 PM
Sorry, misunderstood your question then.