1

我的模型有 clientName model/AlertConfig.js:

Ext.define('ET.model.AlertConfig', {
    extend: 'Ext.data.Model',
    fields: [
             {name: 'id', type: 'string'},
             {name: 'clientName', type: 'string' },
             {name: 'description', type: 'string'},

传入的 xml 嵌入了整个客户端对象(如果存在):

<alertConfig>

    <commandType>D</commandType>
    <countThreshold>1</countThreshold>
    <description>Distributions that failed(all clients)</description>
    <id>2</id>
    <processTimeExceedsSec>0</processTimeExceedsSec>
    <status>3</status>
    <windowMinutes>120</windowMinutes>
  </alertConfig>
  <alertConfig>
    <client>
      <clientCategory>abc</clientCategory>
      <clientExtId>12345</clientExtId>
      <clientId>1</clientId>
      <clientName>MyClient1</clientName>
      <lastModified>2013-03-19T16:12:54.774-04:00</lastModified>
    </client>
    <commandType>R</commandType>
    <countThreshold>1</countThreshold>
    <description>Requests that failed</description>
    <id>3</id>
    <processTimeExceedsSec>0</processTimeExceedsSec>
    <status>3</status>
    <windowMinutes>120</windowMinutes>
  </alertConfig>

问题:

我只需要将 alertConfig/client/clientName 映射到模型中的 clientName。我怎样才能干净地做到这一点。有没有我可以提到这个 xml 路径的地方?

注意:在视图中用户将看到客户端名称(以及组合框中的所有客户端名称,用户可以选择并使用不同的客户端名称更新警报。)

4

1 回答 1

0

通过添加'/'解决

Ext.define('ET.model.AlertConfig', {
    extend: 'Ext.data.Model',
    fields: [
             {name: 'id', type: 'string'},
             {name: 'clientId', mapping: 'client/clientId', type: 'int' }, 
             //not a field in erf.domain (but points to Client object)
             {name: 'clientName', mapping: 'client/clientName', type: 'string' }, // not a field in erf.domain
             {name: 'description', type: 'string'},
于 2013-04-19T15:46:05.970 回答