View Full Version : load event not firing in jsonstore

17 Aug 2011, 6:26 AM
I'm having a jsonstore to load my list. I'm loading store using inline data without any proxy config. I wanted to call load event of my store. Kindly let me know how to do it.Below is my store code:

Store = new Ext.data.JsonStore({
model : 'SettingModel',
getGroupString:function(){ return 'Set Duration'; },
data: [ {name: '5 mins', value: '5'}, {name: '15 mins', value: '15'}, {name: '25 mins', value: '25'}, {name: '45 mins', value: '45'}],
listeners : { 'load': function(){ Ext.Msg.alert('App',"load");

with the above code i get the following error message : "Uncaught Error: You are using a ServerProxy but have not supplied it with a url"

if i remove the "Store.load();" line, im not getting error and list is populating with data. But the load event is not fired.

Kindly help me how to make load event to fire in this scenario.

Thanks in Advance

17 Aug 2011, 9:50 AM
You'll need to read up on the samples for defining your proxy in your store. If the store itself can be thought of as an array controller; then your proxy is the networking involved in loading up the store with content.

If you're using a localstore then you can define a proxy for that; if you're using a rest server to provide data it would look like:

new Ext.data.JsonStore({
proxy: { type: "rest", url: "/pathtodata", reader:{type:"json",root:"result"} },
/* provides data in a nested array where the base item is "result" => {some data}) */

I believe the message you're seeing now is that the unspecified nature of your proxy leaves Ext without any idea where the data comes from.

17 Aug 2011, 1:02 PM
what about :

// build store with no data
new Ext.data.JsonStore({
data: [], // plz check if 'data' is mandatory or not

// then loadData
Store.loadData([ {name: '5 mins', value: '5'}, {name: '15 mins', value: '15'}]);

24 Aug 2011, 8:01 PM
yea the above code snippet worked for me .