我的 Json 数据:-
{
"attributes": {
"list": [
{
"name":"attribute2",
"value":"attribute2 value"
}, {
"name":"attribute1",
"value":"attribute1 value"
}]
}
"name":"name1",
"id":1234
}
我的商店定义:-
Ext.define('Attr', {
extend: 'Ext.data.Store',
model: 'Attribute',
autoLoad: true,
proxy: {
type: 'rest',
url: 'data/1234',
api: {
update: 'newdata/1234'
},
reader: {
type: 'json',
root: 'attributes.list'
}
}
});
我的模型定义:-
Ext.define('Attribute', {
extend: 'Ext.data.Model',
fields: ['name','value']
});
显示上述商店的视图:-
{
xtype: 'grid',
store: 'Attr',
id: 'attrpanel',
columns: [
{
header: 'Name',
sortable: true,
dataIndex: ['name'],
flex: 1
}, {
header: 'Value',
sortable: true,
dataIndex: ['value'],
flex: 1
}]
}
当前情况:我可以显示来自 Json 对象的数据值。
问题:每当我在编辑字段后在控制器中调用 this.getAttrStore().sync() 时,都会出现错误。我搜索了许多论坛并意识到在更新深度嵌套的 JSON 数据时似乎存在一些问题。
我曾想过获得彼得穆勒的补丁,但我还没有真正尝试过。
如果我错了,或者如果你能指出一些有用的东西,请纠正我,这将是一个很大的帮助。
非常感谢!