我有這樣的JSON:ExtJS的6網+ JSON
{
"aaa": {
"list": {
"count":"1",
"data": [
{"id":"1","username":"user1","email":"[email protected]"}
]
}
}
}
這是我的商店:
var store = Ext.create('Ext.data.Store', {
fields : [ 'id',
'username',
'email'],
autoLoad : true,
proxy: {
type: 'ajax',
api: {
read: 'server/users'
},
reader: {
type: 'json',
successProperty: 'success',
root: 'data',
messageProperty: 'message'
}
}
});
這是我的網格:
xtype: 'grid',
title: 'Users',
id: 'users',
store: store,
columns: {
items: [
{text: 'ID', dataIndex: 'id', editor: 'textfield'},
{text: 'Name', dataIndex: 'name', editor: 'textfield' },
{text: 'Email', dataIndex: 'email', editor: 'textfield' },
]
},
但是這個代碼是不工作。我沒有在我的網格上顯示JSON數據。我認爲問題是我沒有達到JSON元素。
我該如何達到這個要素? (aaa.data.id,aaa.data.name,aaa.data.email不起作用)
如果路徑始終是靜態的,您可以在''''''config''中指定'root':'aaa.list.data' – weeksdev