0

我定义了以下模型:

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' } } })
4

1 回答 1

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'
        }
    }
});
于 2013-07-09T15:20:52.297 回答