我正在使用带有treestore和treemodel的treepanel,其中包含3个级别的节点。我想将节点添加到商店,然后通过服务器api同步商店。所有这些都适合阅读嵌套商店。以下是我将get发送到服务器api时的数据示例:
{
"children" : [{
"region" : 1,
"label" : "Paris",
"children" : [{
"schoolId" : 1,
"type" : "elementry"
"address" : "1 rue generale",
"children" : [{
"classId" : 1,
"teacher" : "Smith",
"year" : 1,
"leaf" : true
}, {
"classId" : 2,
"teacher" : "Alan",
"year" : 1,
"leaf" : true
}, {
"classId" : 3,
"teacher" : "Larkin",
"year" : 2,
"leaf" : true
}, {
"classId" : 4,
"teacher" : "Sharp",
"year" : 2,
"leaf" : true
}
]
}, {
"schoolId" : 2,
"type" : "elementry"
"address" : "1 rue de gaulle",
"children" : [{
"classId" : 5,
"teacher" : "Mathew",
"year" : 1,
"leaf" : true
}, {
"classId" : 6,
"teacher" : "Mark",
"year" : 1,
"leaf" : true
}, {
"classId" : 7,
"teacher" : "Luke",
"year" : 2,
"leaf" : true
}, {
"classId" : 8,
"teacher" : "John",
"year" : 2,
"leaf" : true
}
]
}, {
"schoolId" : 3,
"type" : "middle"
"address" : "99 avenue de larre",
"children" : [{
"classId" : 7,
"teacher" : "Lisa",
"year" : 5,
"leaf" : true
}, {
"classId" : 8,
"teacher" : "Bart",
"year" : 6,
"leaf" : true
}]
}]
}]
}
但是,当我添加子节点并发送sync命令时,生成的post请求不会嵌套。附加子节点的代码:
var store = me.getViewModel().getStore('schoolStore');
var region = new WEBI.model.Region({
"label" :"Bordeaux"
});
var school = new WEBI.model.School({
"type" : "elementry",
"address" : "10 rue Bidart"
});
region.appendChild(school);
store.root.appendChild(region);
store.sync();
发布请求中的数据采用以下格式:
[{
"label" : "Bordeaux"
"region" : "Region-1",
"parentId" : "root",
"leaf" : false
}, {
"type" : "elementry",
"address" : "10 rue Bidart"
"idtsl2" : "School-1",
"parentId" : "Region-1",
"leaf" : false
}]
我期待/希望帖子请求嵌套itmes,即具有以下格式
[{
"label" : "Bordeaux"
"region" : "Region-1",
"parentId" : "root",
"leaf" : false,
"children" : [{
"type" : "elementry",
"address" : "10 rue Bidart"
"idtsl2" : "School-1",
"parentId" : "Region-1",
"leaf" : false
}
]
}]
有没有其他人看到同样的问题。这是一个必须处理以这种格式发布请求的问题,还是有一些方法可以配置我的代理/模型以嵌套格式发送帖子?