2013-01-31 28 views
3

我有一个包含与另一个模型的关联的模型。我能够通过使用字段上的映射属性将嵌套数据显示到表单中。例如:将嵌套的表单数据保存到ExtJS中的服务器中

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)将模型中的数据拖入表单中。

然而,现在我想将数据发送回服务器,我得到的错误:

Error performing action. Please report the following: "Unrecognized field "plan.surveyor"

我试图通过先调用Form.updateRecord保存到服务器(模型),然后model.save()。有没有办法让作家明白'plan.surveyor'不是一个属性名称,而是正确处理嵌套?

我是以这种正确的方式开始使用,还是应该处理表单数据的设置并以更加手动的方式重新加载到模型中?似乎嵌套的数据并不是一般都支持的 - 任何建议?

回答

0
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 
      } 
     ], 

变化,即显示评论,因为数据索引在上面的格式给出,因为乌尔给乌尔格式综合类时未dataindex这是一列或ExtJS的准备,所以请更改可能它的工作做好

这是不行的,你会发送洞码

相关问题