Javascript 在ExtJS中将嵌套表单数据保存回服务器
我有一个模型,其中包含与另一个模型的关联。我可以使用字段上的映射属性将嵌套数据显示到表单中。例如:Javascript 在ExtJS中将嵌套表单数据保存回服务器,javascript,extjs,model,extjs4,Javascript,Extjs,Model,Extjs4,我有一个模型,其中包含与另一个模型的关联。我可以使用字段上的映射属性将嵌套数据显示到表单中。例如: Ext.define('Example.model.Request', { extend: 'Ext.data.Model', fields: [ { name: 'id', type: Ext.data.Types.NUMBER, useNull: false }
Ext.define('Example.model.Request', {
extend: 'Ext.data.Model',
fields: [
{
name: 'id',
type: Ext.data.Types.NUMBER,
useNull: false
}
{
name: 'plan_surveyor',
mapping: 'plan.surveyor',
type: Ext.data.Types.STRING
}
],
associations: [
{type: 'hasOne', associationKey: 'plan', getterName:'getPlan', model: 'Specs.model.Plan'}
],
proxy: {
type: 'direct',
api: {
read: requestController.load,
update: requestController.update,
},
reader: {
type: 'json',
root: 'records'
},
writer: {
type: 'json',
writeAllFields: true,
nameProperty: 'mapping'
}
}
});
使用此方法,我可以通过参考plan_surveyor在表单中显示plan.surveyor值。我调用Form.loadRecord(model)将数据从模型拉入表单
但是,现在我正试图将数据发送回服务器,因此出现了以下错误:
执行操作时出错。请报告以下内容:“未识别的场地”平面图。测量员“
我试图通过先调用Form.updateRecord(model),然后调用model.save()来保存到服务器。有没有办法让编写者理解“plan.explorer”不是属性名,而是正确处理嵌套
我这样做是正确的开始方式,还是应该只是处理表单数据的设置并以更手动的方式加载回模型中?看起来嵌套数据通常没有得到很好的支持-有什么建议吗
Ext.define('Example.model.Request', {
extend: 'Ext.data.Model',
fields: [
{
name: 'id',
type: Ext.data.Types.NUMBER,
useNull: false
}
{
name: 'plan_surveyor',
mapping: 'plan.surveyor',//change to 'plan_surveyor'
type: Ext.data.Types.STRING
}
],
更改注释中显示的内容,因为数据索引是以上述格式给出的,因为ur给出的格式不是dataindex,而是列或extjs,所以请更改,这样可能会很好地工作
这不是工作,你会发送孔代码