與this question類似,我無法讓我的DataView實際顯示數據。我試圖重新調整我的商店,但我想我錯過了一些東西。下面是我到目前爲止有:如何爲Ext.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>'
}
]
});
JSON
[
{
"id": "1",
"name": "sam",
"age": "4"
},
{
"id": "2",
"name": "jack",
"age": "3"
},
{
"id": "3",
"name": "danny",
"age": "12"
}
]
有什麼建議嗎?所有與此類似的其他問題都使用Ext.JsonStore,但Sencha API文檔說這樣做。
UPDATE
該店工作的罰款。下面是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
...
更好的問題:我如何得到一個Ext.DataView只顯示一個項目?硬模式:過濾商店不起作用。 – Yoshokatana
TestApp.stores.storeMe.data的輸出是什麼? –
它給了我三件物品。我將它添加到主要問題中。 – Yoshokatana