开发者

Loading data into JsonStore

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 ab开发者_Go百科out record count


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜