将嵌套表单数据保存回ExtJS中的服务器 [英] Save nested form data back to server in ExtJS
问题描述
Ext.define('Example.model.Request',{
extends:'Ext.data。模型',
字段:[
{
名称:'id',
类型:Ext.data.Types.NUMBER,
useNull:false
}
{
名称:'plan_surveyor',
映射:'plan.surveyor',
类型:Ext.data.Types.STRING
}
关联:[
{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'
},
writ呃:{
type:'json',
writeAllFields:true,
nameProperty:'mapping'
}
}
}) ;
使用此方法,可以通过引用plan_surveyor在表单中显示plan.surveyor值。我调用Form.loadRecord(model)将数据从模型中拉入到表单中。
但是,现在我试图将数据发送回服务器,我收到错误:
执行操作时出错。请报告以下内容:无法识别的字段plan.surveyor
我试图通过首先调用Form.updateRecord模型),然后是model.save()。有没有办法让Writer了解plan.surveyor不是属性名称,而是正确处理嵌套?
我正在做这个开始的正确方法,还是应该正式处理表单数据的设置,并以更为手工的方式加载到模型中?似乎嵌套数据一般不是很好的支持 - 任何建议?
Ext.define('Example.model.Request' {
extends:'Ext.data.Model',
fields:[
{
name:'id',
type:Ext.data .Types.NUMBER,
useNull:false
}
{
name:'plan_surveyor',
映射:'plan.surveyor',//更改为'plan_surveyor'
类型:Ext.data.Types.STRING
}
],
更改在评论中显示,因为数据索引以上述格式给出,因为ur给出的url格式是不是dataindex的时间它是一列或者extjs的准备,所以请更改,这可能是很好的
它不工作你将发送孔代码
I have a Model that contains an association to another Model. I am able to display the nested data into a form by using the mapping attribute on the field. Example:
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'
}
}
});
Using this method, I can display the plan.surveyor value in the form by reference plan_surveyor. I call Form.loadRecord(model) to pull the data from the model into the form.
However, now that I'm trying to send the data back to the server, I get the error:
Error performing action. Please report the following: "Unrecognized field "plan.surveyor"
I am attempting to save to the server by first calling Form.updateRecord(model), then model.save(). Is there a way to have the Writer understand that 'plan.surveyor' is not a property name but instead to properly handle nesting?
Am I doing this the right way to start with, or should I just be handling the setting of the form data and loading back into the model in a more manual fashion? It seems that nested data is not all that well supported in general - any recommendations?
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
}
],
change that show in comment ,because data index is given in above format because ur give ur format thata time that is not dataindex it's a column or extjs preparatory ,so please change that may it's work well
it's not work u will send hole code
这篇关于将嵌套表单数据保存回ExtJS中的服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!