我試圖將一些簡單的數據導入到JsonStore中,但它似乎不起作用。代碼與示例幾乎相同:將數據加載到JsonStore中
var itemListStore = new Ext.data.JsonStore({
url: '/items/list',
root: 'items',
fields: [
{name: 'id', type: 'string'},
{name: 'name', type: 'string'},
]
});
itemListStore.load();
...
items: [
{
xtype: 'listview',
store: itemListStore,
columnResize: false,
flex: 1,
columns: [
{header: 'ID', dataIndex: 'id'},
{header: 'Name', dataIndex: 'name'},
]
}
...
不幸的是,這不起作用。該表加載時沒有行,並且存儲上的計數是68(由服務器返回,通過listview.getStore().getCount()
得到)。如果我用一個ArrayStore和一些靜態數據替換JsonStore,我可以看到它們。
從/items/list
結果就是:
{"items":
[{"id": "a", "name": "Some name"},
{"id": "b", "name": "Some other name"}]
}
我該如何解決這個問題?我怎樣才能調試呢?
編輯:已更新記錄計數
如果從控制檯你Ext.getCmp('yourlistview')。getStore()。reload(),你能看到XHR返回嗎? – Orbit 2010-10-24 17:20:35
@Brandon - 當我運行這個時,我返回undefined,但通過網絡發出正確的請求(根據螢火蟲)。 – viraptor 2010-10-24 17:30:24
如果將xtype更改爲網格,它可以工作嗎? ;) – Orbit 2010-10-24 17:52:06