PDA

View Full Version : Creating JSON store using GET



marchoward90
29 Apr 2014, 1:24 AM
I have a method that returns JSON data and i want to be able to create a store based on that data returned. I have tried this version below.. but the store is still empty. I know that the JSON method returns data to the browser and is in the correct format. Any help would be great.


var cstore = new Ext.data.Store({
id: 'datestore',
autoLoad: true,
proxy: new Ext.data.HttpProxy({
url: '/ext/calculateownershipdata',
method: 'GET'
}),
reader: new Ext.data.JsonReader({
root: 'items',
totalProperty: 'totalCount',
fields: ['value', 'label']
})
});


JSON Data:

{"items":[{"value":83,"label":"Mr Jones"}]}

Kachopsticks
29 Apr 2014, 10:55 AM
The only thing that I am questioning is your url param. If you are certain that the url path you provided is correct, I would try adding the file extension to the end of it. I do not use HttpProxy, I use AJAX, and when I specify the URL I do not specify a file extension. Maybe because you are doing an HttpProxy you need to specify it. If you look at the examples in the documentation, they all specify a file extension. Sorry this is not a certain fix, but it may be worth a try.

http://docs.sencha.com/extjs/3.4.0/#!/api/Ext.data.DataProxy

marchoward90
30 Apr 2014, 2:35 AM
Thanks, all working now!