Sencha Touch:Ext.DataView未显示商店数据 [英] Sencha Touch: Ext.DataView not showing store data

查看:12
本文介绍了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

myallback({"Results":{"html":"...为简洁起见删除内容..."},"Success":True});

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

没有控制台/Java脚本错误。资源显示,我实际上是从WebService中删除了JSON。

如果我在AboutController上的activate侦听程序中使用console.log(rpc.stores.AboutStore.getCount());,结果始终为0,我不完全确定原因

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

推荐答案

尝试将json值作为数组而不是对象返回。我认为Ext需要一个记录数组,而不是只有一个。

例如

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

这篇关于Sencha Touch:Ext.DataView未显示商店数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆