Json 如何为Ext.DataView构造数据?

Json 如何为Ext.DataView构造数据?,json,sencha-touch,extjs,Json,Sencha Touch,Extjs,与之类似,我无法让我的DataView实际显示数据。我试图重组我的商店,但我想我错过了一些东西。以下是到目前为止我得到的信息: 应用程序、型号、商店 Ext.regApplication({ name: 'TestApp', launch: function() { this.viewport = new TestApp.views.Viewport(); } }); TestApp.models.StoreMe = Ext.regModel('Test

与之类似,我无法让我的DataView实际显示数据。我试图重组我的商店,但我想我错过了一些东西。以下是到目前为止我得到的信息:

应用程序、型号、商店

Ext.regApplication({
    name: 'TestApp',
    launch: function() {
        this.viewport = new TestApp.views.Viewport();
    }
});

TestApp.models.StoreMe = Ext.regModel('TestApp.models.StoreMe', {
    fields: [
        'id',
        'name',
        'age'
    ]
});

TestApp.stores.storeMe = new Ext.data.Store({
    model: 'TestApp.models.StoreMe',
    proxy: {
        type: 'ajax',
        url: 'data.json',
        reader: {
            type: 'json'
        }
    },
    autoLoad: true
});
视口和数据视图

TestApp.views.Viewport = Ext.extend(Ext.Panel, {
    fullscreen: true,
    layout: 'card',
    items: [
        {
            id: 'dataView',
            xtype: 'dataview',
            store: TestApp.stores.storeMe,
            itemSelector: 'div.dataViewItem',
            emptyText: 'NO DATA',
            tpl: '<tpl for "."><div class="dataViewItem">ID: {id}<br />Name: {name}<br />Age: {age}</div></tpl>'
        }
    ]
});
有什么想法吗?与此类似的所有其他问题都使用Ext.JsonStore,但Sencha API文档表示可以这样做

更新

这家商店运转良好。下面是TestApp.stores.storeMe.data的样子:

Ext.util.MixedCollection
    ...
    items: Array[3]
        0: c
            data: Object
                age: "4"
                id: "1"
                name: "sam"
        1: c
        2: c
        length: 3
        __proto__: Array[0]
    keys: Array[3]
    length: 3
    ...

似乎您没有根名为“data”的json结构?尝试将json更改为:

{
    "data": [ {
        "id": "1",
        "name": "sam",
        "age": "4"
    }, {
        "id": "2",
        "name": "jack",
        "age": "3"
    }, {
        "id": "3",
        "name": "danny",
        "age": "12"
    } ]
}
然后在你的阅读器里放一行字——root:‘data’。

我是个白痴。我有:

tpl: '<tpl for "."><div class="dataViewItem">ID: {id}<br />Name: {name}<br />Age: {age}</div></tpl>'
tpl:'ID:{ID}
Name:{Name}
Age:{Age}'
我需要:

tpl: '<tpl for=".">...</tpl>'
第三方物流:“…”
仍然不起作用。我想这可能与商店里不止一件物品有关。不过,当我添加一个过滤器时,它仍然无法修复它。@Yoshokatana,这不太可能。您确定您的存储包含数据吗?试试TestApp.stores.storeMe.data.Better问题:如何让Ext.DataView只显示一个项目?硬模式:筛选存储不起作用。TestApp.stores.storeMe.data的输出是什么?它给了我三项。我把它添加到主要问题中。祝贺你解决了这个问题。当你有能力时,请确保将你的答案标记为“已接受”,以便其他人可以从你的成功中学习。干杯~
tpl: '<tpl for=".">...</tpl>'