2011-01-19 20 views
0

我想从ExtDirect路由器加载网格数据。结果包含一个应重新配置商店字段的元数据对象。但是我收到以下错误,当我尝试加载我的数据:ExtJS DirectStore中字段的元数据配置

Uncaught TypeError: Cannot read property 'sortType' of undefined (ext-all-debug.js:23943) 

JSON结果:

{ 
    "action": "Dashboard", 
    "method": "dashboarddata", 
    "type": "rpc", 
    "result": { 
     "success": true, 
     "metaData": { 
      "sortInfo": { 
       "direction": "ASC", 
       "field": "id" 
      }, 
      "fields": [{ 
       "mapping": "id", 
       "id": "id" 
      }, 
      { 
       "mapping": "owner", 
       "id": "owner" 
      }, 
      { 
       "mapping": "name", 
       "id": "name" 
      }, 
      { 
       "mapping": "type", 
       "id": "type" 
      }, 
      { 
       "mapping": "strategy", 
       "id": "strategy" 
      }, 
      { 
       "mapping": "primebroker", 
       "id": "primebroker" 
      }, 
      { 
       "mapping": "startdate", 
       "id": "startdate" 
      }, 
      { 
       "mapping": "date_afc_prelim_approval", 
       "id": "date_afc_prelim_approval" 
      }, 
      { 
       "mapping": "date_afc_approval", 
       "id": "date_afc_approval" 
      }, 
      { 
       "mapping": "date_submit_regulator", 
       "id": "date_submit_regulator" 
      }, 
      { 
       "mapping": "date_approval_regulator", 
       "id": "date_approval_regulator" 
      }, 
      { 
       "mapping": "enddate", 
       "id": "enddate" 
      }, 
      { 
       "mapping": "main_iso_currency", 
       "id": "main_iso_currency" 
      }, 
      { 
       "mapping": "nav_frequency", 
       "id": "nav_frequency" 
      }, 
      { 
       "mapping": "date_first_nav", 
       "id": "date_first_nav" 
      }, 
      { 
       "mapping": "launch_size", 
       "id": "launch_size" 
      }, 
      { 
       "mapping": "target_size", 
       "id": "target_size" 
      }, 
      { 
       "mapping": "memo", 
       "id": "memo" 
      }, 
      { 
       "mapping": "isin_codes", 
       "id": "isin_codes" 
      }, 
      { 
       "mapping": "status", 
       "id": "status" 
      }], 
      "totalProperty": "total", 
      "successProperty": "success", 
      "idProperty": "id", 
      "root": "data" 
     }, 
     "data": [{ 
      "status": "Project closed", 
      "strategy": "Strategy X", 
      "date_afc_approval": "2010-01-01", 
      "startdate": "2010-01-01", 
      "nav_frequency": "Bi-monthly", 
      "date_first_nav": "2010-01-01", 
      "enddate": "2010-01-01", 
      "date_approval_regulator": "2010-01-01", 
      "id": "1", 
      "date_afc_prelim_approval": "2010-01-01", 
      "isin_codes": "123", 
      "target_size": "2000", 
      "owner": "Some name", 
      "name": "First project", 
      "memo": "TEXTEXTEXT", 
      "main_iso_currency": "TND", 
      "primebroker": "Yes", 
      "date_submit_regulator": "2010-01-01", 
      "launch_size": "1000", 
      "type": "TypeX" 
     }], 
     "total": 1 
    }, 
    "tid": 6 
} 

商店本身的配置,如:

var store = new Ext.data.DirectStore({ 
     idProperty: 'id' 
     ,paramsAsHash: true 
     ,directFn: MyApp.Direct.Dashboard.dashboarddata 
     ,root:'data' 
     ,autoLoad: false 
     ,totalProperty:'total' 
     ,fields: [ 
      {name: 'id', mapping: 'id'}, 
      {name: 'type', mapping: 'type'} 
     ] 
     ,baseParams: { 
      type: this.type, 
      filters: this.filters 
     } 
    }); 

任何人都可以请帮帮我?这让我疯狂,我看不出我做错了什么。

谢谢!

Rob

PS。我正在使用ExtJS 3.3.0

回答

1

我修好了。调试完成了。

显然,当通过JSON响应中的元数据对象更新字段时,您需要命名这些字段。 ExtJS在内部使用名称字段作为查找字段。奇怪的是,与商店的领域的静态配置,你不需要该领域...

... 
"fields": [{ 
       "mapping": "id", 
       "name": "id", 
       "id": "id" 
      }, 
      { 
       "mapping": "owner", 
       "name": "owner", 
       "id": "owner" 
      }, 
      ... 
1

为什么不使用Chrome或Firefox调试工具来调试那个地方?有用的选项是在Chrome中设置例外中断。

+0

嗯,曾经试过调试ExtJS? :)大量的代码行来通过。无论如何,我认为这是我最好的选择。 – 2011-01-19 21:12:28