这是我的JSON:
[{
"ActionBy": "om",
"ActionDate": "11\/26\/2013 8:50:56 AM",
"ActionDetails": [{
"Field": "St",
"NewValue": "Clo",
"OldValue": "Ch",
"UpdateType": "Tie"
}, {
"Field": "AssignedTo",
"NewValue": "mus",
"OldValue": "n",
"UpdateType": "As"
}]
这是我的商店:
historyStore = Ext.create('Ext.data.Store', {
fields: ['Field', 'NewValue', 'OldValue'],
autoLoad: true,
proxy: {
type: 'ajax',
url: url,
reader: {
type:'json',
root:''
}
},
listeners:{
load:function(that,records,view){
console.log(records);
}
},
autoLoad: true
});
我希望在网格面板中显示字段NewValue
和OldValue
,
但它不起作用Store,在我看来,我是根本问题。
这是真的JSON吗? 我需要写什么给Root?
答案 0 :(得分:0)
您的json无效,您可以使用jsonlint.com验证您的json。
添加'}]'到您的json以完成它。
将root值赋予ActionDetails,以便从该节点获取数据,如
root:'ActionDetails'
答案 1 :(得分:0)
你的json应该像:
{
"ActionBy": "nimet.seyman@beqom.com",
"ActionDate": "11\/26\/2013 8:50:56 AM",
"ActionDetails": [
{
"Field": "State",
"NewValue": "Closed",
"OldValue": "Check",
"UpdateType": "Ticket Update"
},
{
"Field": "AssignedTo",
"NewValue": "mustafa.arikci@beqom.com",
"OldValue": "nimet.seyman@beqom.com",
"UpdateType": "Assignment"
}
]
}
如果是这样的话:
data =[{
"ActionBy": "nimet.seyman@beqom.com",
"ActionDate": "11\/26\/2013 8:50:56 AM",
"ActionDetails": [
{
"Field": "State",
"NewValue": "Closed",
"OldValue": "Check",
"UpdateType": "Ticket Update"
},
{
"Field": "AssignedTo",
"NewValue": "mustafa.arikci@beqom.com",
"OldValue": "nimet.seyman@beqom.com",
"UpdateType": "Assignment"
}
]
}]
您的商店:
historyStore = Ext.create('Ext.data.Store', {
fields: ['Field', 'NewValue', 'OldValue'],
autoLoad: true,
proxy: {
type: 'ajax',
url: url,
reader: {
type:'json',
root:'ActionDetails'
}
}
});