Sencha Touch:Ext.DataView未显示存储数据



我知道DataView为空的典型原因是因为模型或JSON错误。据我所知,我的是对的。。。所以我不确定为什么我的DataView是空白的。

控制器

rpc.controllers.AboutController = new Ext.Panel({
    id: 'rpc-controllers-AboutController',
    title: 'About',
    iconCls: 'info',
    layout: 'card',
    scroll: 'vertical',
    items: [rpc.views.About.index],
    dockedItems: [{ xtype: 'toolbar',
        title: 'RockPointe Church | Mobile'
    }],
    listeners: {
        activate: function () {
            if (rpc.stores.AboutStore.getCount() === 0) {
                rpc.stores.AboutStore.load();
            }
        }
    }
});

查看

rpc.views.About.index = new Ext.DataView({
    id: 'rpc-views-about-index',
    itemSelector: 'div.about-index',
    tpl: '<tpl for="."><div class="about-index">{html}</div></tpl>',
    store: rpc.stores.AboutStore,
    fullscreen: true,
    scroll: 'vertical'
});

存储

rpc.stores.AboutStore = new Ext.data.Store({
    id: 'rpc-stores-aboutstore',
    model: 'rpc.models.AboutModel',
    autoLoad: true,
    proxy: {
        type: 'scripttag',
        url: WebService('About', 'Index'),
        method: 'GET',
        reader: {
            type: 'json',
            root: 'results'
        },
        afterRequest: function (request, success) {
            if (success) {
                console.log("success");
            } else {
                console.log("failed");
            }
            console.log(request);
        }
    }
});
rpc.stores.AboutStore.proxy.addListener('exception', function (proxy, response, operation) {
    console.log(response.status);
    console.log(response.responseText);
});

型号

rpc.models.AboutModel = Ext.regModel('rpc.models.AboutModel', {
    fields: ['html']
});

JSON

mycallback({"results":{"html":"…为简洁起见删除了内容…"},"success":true});

有人能看到我在这里可能做错了什么吗?

没有控制台/javascript错误。参考资料显示,我实际上正在从WebService中删除JSON。

如果我在AboutController上的activate侦听器中使用console.log(rpc.stores.AboutStore.getCount());,结果总是0,并且我不完全确定的原因

如果您想查看请求,这是暂存应用程序
http://rpcm.infinitas.ws/(注意,此链接将在某个时候过期)

尝试将json值作为数组而不是对象返回。我认为Ext期望的是一个记录数组,而不是一个。

例如

"{results:[{"html":"Your html"}]}"

最新更新