Sencha Touch 2 - JSONP代理帮助,模板的值始终为null

Sar*_*els 5 javascript jsonp model sencha-touch sencha-touch-2

我无法将实际数据显示在Sencha Touch 2列表中.该列表应该由JSONP响应填充,我希望显示2行.相反,我得到一行'null at null'.

这是发送的URL:

http://some-server/data-fetcher.php?_dc=1331910031292&events=true&page=1&start=0
  &limit=25&callback=Ext.data.JsonP.callback1
Run Code Online (Sandbox Code Playgroud)

这是JSONP响应:

Ext.data.JsonP.callback1({"data":[{"id":"4","name":"Sample Name 1",
  "description":null,"location":"Sample Location 1",
  "start_time":"2012-03-22 00:00:00","end_time":null},{"id":"5",
  "name":"Sample Name 2","description":null,"location":"Sample Location 2",
  "start_time":"2012-03-31 00:00:00","end_time":null}],"num_rows":2});
Run Code Online (Sandbox Code Playgroud)

这是我的模特:

Ext.define('MyApp.model.Event', {
    extend: 'Ext.data.Model',
    config : {
        idProperty: 'id',
        fields : [ {
            name : "id",
            type : "int"
        }, {
            name : "name",
            type : "string"
        }, {
            name : "description",
            type : "string"
        }, {
            name : "location",
            type : "string"
        }, {
            name : "start_time",
            type : "date"
        }, {
            name : "end_time",
            type : "date"
        } ]
    }
});
Run Code Online (Sandbox Code Playgroud)

这是我的商店:

Ext.define('MyApp.store.EventsOnline', {
    extend  : 'Ext.data.Store',
    requires: ['MyApp.model.Event'],
    config  : {
        model : 'MyApp.model.Event',
        autoLoad : true,
        proxy : {
            type : 'jsonp',
            url : 'http://some-server/data-fetcher.php',
            reader : {
                type : 'json',
                root : 'data',
                totalCount : 'num_rows'
            },
            callbackKey : 'callback',
            extraParams : {
                'events' : true
            }
        }
    }
});
Run Code Online (Sandbox Code Playgroud)

这是我的观点:

Ext.define('MyApp.view.Event', {
    extend: 'Ext.Container',
    config : {
        layout : {
            type : 'vbox',
            align : 'stretch'
        },
        fullscreen : true,
        flex : 1,
        items : [
            {
                xtype : 'toolbar',
                docked : 'top',
                title : 'Events'
            }, {
                xtype   : 'list',
                flex    : 1,
                store : 'EventsOnline',
                itemTpl : '{name} at {location}'
            }
        ]
    }
});
Run Code Online (Sandbox Code Playgroud)

我希望在我的清单中看到的是:

Sample Name 1 at Sample Location 1
Sample Name 2 at Sample Location 2
Run Code Online (Sandbox Code Playgroud)

而我所看到的只是:

null at null
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

编辑:如果重要,这是我的应用程序和控制器:

Ext.Loader.setConfig({enabled : true});

Ext.application({
    name               : 'MyApp',
    appFolder          : 'app',
    controllers : ['Home'],
    launch : function() {
        window[this.getName()].app = this;
    }
});

Ext.define('MyApp.controller.Home', {
    extend: 'Ext.app.Controller',
    models: ['Event'],
    stores: ['EventsOnline'],
    views: ['Event'],
    init: function () {
        var me = this;
        Ext.Viewport.add(Ext.create('MyApp.view.Event'));
    }
});
Run Code Online (Sandbox Code Playgroud)

mez*_*eze 3

root : 'data',
totalCount : 'num_rows'
Run Code Online (Sandbox Code Playgroud)

已弃用。使用:

rootProperty: 'data',
totalProperty: 'num_rows'
Run Code Online (Sandbox Code Playgroud)

确保您包含 Sencha Touch 来sencha-touch-all-compat.js进行开发。它将在浏览器控制台中报告您使用的所有已弃用的内容。