我的模型有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路径的地方?
注意:在视图中,用户将看到ClientName(以及组合框中的所有客户端名称,用户可以选择&amp; update,使用不同的clientName作为警报。)
答案 0 :(得分: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'},