views:

26

answers:

1

Hi, I'm trying to get some simple data into a JsonStore, but it doesn't seem to work. The code is pretty much the same as examples:

var itemListStore = new Ext.data.JsonStore({
   url: '/items/list',
   root: 'items',
   fields: [
      {name: 'id', type: 'string'},
      {name: 'name', type: 'string'},
   ]
});
itemListStore.load(); 
...
      items: [
      {
         xtype: 'listview',
         store: itemListStore,
         columnResize: false,
         flex: 1,
         columns: [
            {header: 'ID', dataIndex: 'id'},
            {header: 'Name', dataIndex: 'name'},
         ]
      }
...

Unfortunately this doesn't work. The table loads with no rows and the count on the store is 68 (as returned by server, got via listview.getStore().getCount()). If I substitute JsonStore with an ArrayStore and some static data, I can see them.

The result from /items/list is just:

{"items":
    [{"id": "a", "name": "Some name"},
    {"id": "b", "name": "Some other name"}]
}

How do I fix this? How do I even debug this?

Edit: updated the information about record count

+1  A: 

can you try with a store like this:

            store: objPlanManagerStore = new Ext.data.Store({
                autoLoad: true,
                proxy: new Ext.data.HttpProxy({
                    url: '/your/url',
                    method: 'POST'
                }),
                reader: new Ext.data.JsonReader({
                    root: 'plans',
                    id: 'id',
                    fields: ['id', 'name', 'descr', 'tname', 'type', 'recurring']
                }),
                listeners: {
                    loadexception: function() {
                        Ext.Msg.alert('Title', 'msg');
                    }
                }
            });

(just pasted from some of my code)

edit: thinking about it, the store doesn't seem to be the problem though.

Orbit
Also requests the data properly, but I see no results. Exception window did not show up.
viraptor