2012-06-07 34 views
0

我有一個像道場Enhaced網格 - 當使用JsonRestStore

[ 
    { 
     "switchType": { 
      "name": "sansayv15", 
      "perform": false, 
      "createBy": null, 
      "createDate": null, 
      "intId": 1, 
      "id": 1 
     }, 
     "collectorType": { 
      "name": "FTP", 
      "perform": false, 
      "createBy": null, 
      "createDate": null, 
      "intId": 1, 
      "id": 1 
     }, 
     "fileType": { 
      "name": "TEXT", 
      "perform": false, 
      "createBy": null, 
      "createDate": null, 
      "intId": 1, 
      "id": 1 
     }, 
     "exportType": { 
      "name": "DB", 
      "perform": false, 
      "createBy": null, 
      "createDate": null, 
      "intId": 1, 
      "id": 1 
     }, 
     "linesToSkip": "1", 
     "checkValidate": "true", 
     "checkDuplicate": "true", 
     "driver": "com.mysql.jdbc.Driver", 
     "url": "jdbc:mysql://localhost:3306/panamaxmediation", 
     "tableName": "sansayv15", 
     "ftpIp": null, 
     "ftpPort": null, 
     "ftpUserName": null, 
     "ftpPassword": null, 
     "sftpIp": null, 
     "sftpPort": null, 
     "sftpUserName": null, 
     "sftpPassword": null, 
     "name": "sansayv15", 
     "password": "root", 
     "userName": "root", 
     "perform": false, 
     "createBy": null, 
     "createDate": null, 
     "intId": 1, 
     "id": 1 
    } 
] 

一個JSON這是作爲從我的服務輸出JsonRestStore,電網沒有顯示數據。 我利用兩個存儲JsonResStore和ObjectStore的這個輸出過MemorryStore爲EnhancedGrid

我在變量定義的網格結構,

var templateGridStructure = [ { 
     name : "ID", 
     field : "id", 
     hidden : "true" 
    }, { 
     name : "Name", 
     field : "name", 
     width : "auto" 
    }, { 
     name : "Collection Method", 
     field : "_item", 
     width : "auto", 
     formatter : function(item) { 
      return item.collectorType.name; 
     } 
    }, { 
     name : "Export Method", 
     field : "_item", 
     width : "auto", 
     formatter : function(item) { 
      return item.exportType.name; 
     } 
    }, { 
     name : "Source File Type", 
     field : "_item", 
     width : "auto", 
     formatter : function(item) { 
      return item.fileType.name; 
     } 
    },{ 
     name : "Duplication Check", 
     field : "checkDuplicate", 
     width : "auto", 
    },{ 
     name : "Validation Check", 
     field : "checkValidate", 
     width : "auto", 

    },{ 
     name : "Switch Type", 
     field : "_item", 
     width : "auto", 
     formatter : function(item) { 
      return item.switchType.name; 
     } 
    } ]; 

當我在EnhancedGrid使用的ObjectStore

templateGrid = new dojox.grid.EnhancedGrid({ 
       id : "templateGrid", 
       name : "templateGrid", 
       store : objectStore}); 

電網是顯示正確的數據 但是,當我在EnhancedGrid中使用JsonRestStore時

templateGrid = new dojox.grid.EnhancedGrid({ 
       id : "templateGrid", 
       name : "templateGrid", 
       store : jsonRestStore}); 

我得到錯誤 - 網格不顯示數據。

這兩個商店之間定義列結構有什麼區別嗎?

回答

0

我發現錯誤,禮貌:道場IRC 「拉維:你不應該直接訪問道場/數據存儲的項目」相反 的,直接使用格式化方法

{ 
     name : "Switch Type", 
     field : "_item", 
     width : "auto", 
     formatter : function(item) { 
      return item.switchType.name; 
     } 
    } 

使用商店商品。的getValue(項目屬性),JsonRestStore,不允許項目

{ 
     name : "Switch Type", 
     field : "_item", 
     width : "auto" , 
     formatter : function(item) { 
      return store.getValue(item,"switchType").name; 
     } 
    } 

我希望直接訪問,有人會得到幫助從這個