View Full Version : JSON not loading in list

25 Mar 2011, 1:23 PM

I'm getting json from a mysql query, the result looks like this:

[{"id":"17","place_id":"17","user_id":"2","group_id":null,"order":"1","category_id":"6","name":"Onze-Lieve-Vrouwekerk","address":"Onze-Lieve-Vrouwestraat 1, Kortrijk","lat":"50.829354","lng":"3.267086","description":"blabla","phone":"","url":"http:\/\/www.kortrijk.be\/adressen\/onze-lieve-vrouwekerk"},{"id":"24","place_id":"24","user_id":"2","group_id":null,"order":"2","category_id":"8","name":"Zwembad Mimosa","address":"Mimosalaan, Kortrijk","lat":"50.816022","lng":"3.283727","description":"blabla","phone":"056 27 80 70","url":""}]

Now I have one model and one store for this data!

this is the MapStore.js file:

STICK.stores.mapstore = new Ext.data.Store({
model: 'MapModel',
proxy: {
type: 'ajax',
url: 'http://localhost:80/2DEV1/MA4_STICK/flash/amfphp/json.php/StickService.getStepsByUserId/2',
reader: {
type: 'json'
autoLoad: true

and this is the MapModel.js file:

Ext.regModel('MapModel', {
fields:[{name: 'id', type: 'int'},
{name: 'place_id', type: 'int'},
{name: 'user_id', type: 'int'},
{name: 'group_id', type: 'int'},
{name: 'order', type: 'int'},
{name: 'category_id', type: 'int'},
{name: 'name', type: 'string'},
{name: 'address', type: 'string'},
{name: 'lat', type: 'double'},
{name: 'lng', type: 'double'},
{name: 'description', type: 'string'},
{name: 'phone', type: 'string'},
{name: 'url', type: 'string'}]

Then in my the js file where i need the store and the data I have this:

STICK.views.MapPanel = Ext.extend(Ext.Panel, {
title: 'Map',
cls: 'map tab',
layout: 'card',
initComponent: function(){
this.items = this.buildItems();

STICK.views.MapPanel.superclass.initComponent.apply(this, arguments);
buildItems: function(me){

var map = new Ext.List({
store: STICK.stores.mapstore,
itemTpl: '{id} ({name})',
onItemDisclosure: function(record) {
console.log(record.data.id + record.data.name);

return map;

Ext.reg('stick-mappanel', STICK.views.MapPanel);

I'm just trying to retrieve the id and the name from the store but when i check the console (STICK.stores.mapstore.data.items) it returns nothing, just []. I guess my store is empty, actually I'm pretty sure but I dont know why its empty?

Any suggestions? I would really appreciate it!

25 Mar 2011, 1:26 PM
The autoLoad config option should be in the store declaration, not the proxy.