2013-08-31 92 views
0

不加載我嘗試從JSON響應轉換列表中加載的值,它沒有顯示任何values.Here我 JSON請求JSON響應列表

http://117.218.59.157:8080/WishList/ShowItems/userID=1 
GET method 

JSON響應

enter image description here

這裏我的清單代碼

Ext.regModel('Filiale', { 
         fields: ['itemID', 'itemName', 'itemImage'], 
         }); 
    var tab= Ext.create('Ext.List', { 
           width: 320, 
           height: 290, 
           model: 'Filiale', 
           store: { 
           fields: ['itemName','itemImage'], 
           proxy: { 
           type: 'ajax', 
           method: 'GET', 
           url : 'http://117.218.59.157:8080/WishList/ShowItems/userID=1', 
           reader: { 
           type: 'json' 
           } 
           } 
           }, 
           itemTpl: '<img src="{itemImage}" width="35" heigh="35"></img><span>&nbsp&nbsp&nbsp{itemName}' 
           }); 

我覺得問題在list.Can語法的任何一個,請幫我解決

回答

1

你忘了設定的JSON readerroot財產。因此,列表組件不知道從哪裏開始!你應該用JSON清單返回root屬性如下圖所示:

{"items": 
    [{ 
    "itemID": "1", 
    "errorMsg": "", 
    "itemName": "Airplane", 
    "itemDesc": "Model NEW 2003" 
    }, 
    { 
    "itemID": "2", 
    "errorMsg": "", 
    "itemName": "Bike", 
    "itemDesc": "Model NEW 2003" 
    } 
    ] 
} 

同時一定要設置JSON讀者idProperty

proxy: { 
    type: 'ajax', 
    url: 'http://117.218.59.157:8080/WishList/ShowItems/userID=1', 
    method: 'GET' 
}, 
reader: { 
    type: 'json', 
    root: 'items', 
    idProperty: 'itemID' 
} 

此外,您沒有設置模型的列類型!限定模型象下面這樣:

Ext.define('Filiale', { 
extend: 'Ext.data.Model', 
fields: [ 
    {name: 'itemID', type: 'int'}, 
    {name: 'itemName', type: 'string'}, 
    {....} 
] 

});