2013-07-09 35 views
0

我定义下列型号列表ExtJS的型号:如何实现期望接收对象

Ext.define('itfm.application.model.SystemHealth', { 
    extend: 'Ext.data.Model', 
fields: [ 
     {name: 'module',   type: 'systemModule'}, 
     {name: 'status',   type: 'SystemModuleStatus'}, 
     {name: 'lastRun',   type: 'long'}, 
     {name: 'lastSuccessfulRun', type: 'long'}, 
     {name: 'nextRun' , type: 'long'}, 
     {name: 'numberOfMinutes', type :'int'}, 
     {name: 'moduleIdentifier' , type : 'string'}, 
     {name: 'duration' , type: 'long'} 
    ] 
}); 

和数据预计从服务器接收的我是:

{ 
    "moduleStatusList": [ 
    { 
     "module": 2, 
     "status": 0, 
     "lastRun": 1373368689143, 
     "lastSuccessfulRun": 1373368689143, 
     "nextRun": 1373378686392, 
     "numberOfMinutes": 159 
    } 
    ] 
} 

我米添加商店:

Ext.define('itfm.application.store.SystemHealth', 
{ extend: 'Ext.data.Store', proxy: { autoLoad: true, type: 'rest', reader: { type: 'json' }, api: { read: 'rest/system-health' } } }) 
+0

您可以发布商店/代理对象的代码吗? – sha

回答

2

这是我如何定义商店在你的情况下,你是缺少一些属性是需要:

Ext.define('itfm.application.store.SystemHealth', { 
    extend: 'Ext.data.Store', 
    model: 'itfm.application.model.SystemHealth', 
    proxy: { 
     autoLoad: true, 
     type: 'rest', 
     reader: { 
      type: 'json', 
      root: 'moduleStatusList' 
     }, 
     api: { 
      read: 'rest/system-health' 
     } 
    } 
});