我正在尝试学习 Ext JS,因为我已经设置了一个项目,需要我了解它的一些基本部分,基本上我坚持以下几点:
我需要基于一个公共字段将两个 JSON 文件加载到同一个表中:
文件 1
{
"data" : [{
"id" : "12",
"data" : {
"field1" : "data 1-1",
"field2" : "data 1-2",
}
},{
"id" : "34",
"data" : {
"field1" : "data 2-1",
"field2" : "data 2-2",
}
}]
}
文件 2:
{
"otherdata" : [{
"id" : "12",
"stuff" : {
"var1" : "stuff 1-1",
"var2" : "stuff 1-2",
},
"morestuff" : {
"v1" : "more 1-1",
"v2" : "more 1-2",
"v3" : "more 1-3"
}
},{
"id" : "34",
"stuff" : {
"var1" : "stuff 2-1",
"var2" : "stuff 2-2",
},
"morestuff" : {
"v1" : "more 2-1",
"v2" : "more 2-2",
"v3" : "more 2-3"
}
}]
}
我想要将这些解析成这样的表:
|-----------------------------------------------------------------------------------
| | data | stuff | morestuff |
|-----------------------------------------------------------------------------------
| id | field1 | field2 | var1 | var2 | v1 | v2 | v3 |
|-----------------------------------------------------------------------------------
| 12 | data 1-1 | data 1-2 | stuff 1-1 | stuff 1-2 | more 1-1 | more 1-2 |more 1-3 |
| 34 | data 2-1 | data 2-2 | stuff 2-1 | stuff 2-2 | more 2-1 | more 2-2 |more 2-3 |
------------------------------------------------------------------------------------
我坚持的是以下几点:
如何加载两个JSON 文件并将它们与一个公共字段链接到一个数据存储中?
如何在数据模型中创建字段和子字段?(我可以创建单个字段,但不知道如何在这些字段中创建字段)
我的模型目前看起来像这样:
Ext.define('NS.model.Group', {
extend: 'Ext.data.Model',
fields: ['id','field1', 'field2', 'var1', 'var2', 'v1', 'v2', 'v3']
});