2012-05-12 52 views
0

我有一個jsonStore這樣爲什麼我的jsonStore沒有任何數據?

var ch01_store = new Ext.data.JsonStore({ 
     autoLoad:true, 

     storeId: 'ch01_store', 
     proxy: new Ext.data.HttpProxy({ 
      url: 'index.php/test/get_ch01/10', 
      method: 'POST' 
     }), 
     root: 'data', 
     totalProperty: 'results', 
     remoteSort: true, 
     fields: [ 
      {name: 'date_time', mapping: 'date_time'}, 
      {name: 'chart_data', mapping: 'chart_data'} 
     ] 
    }); 

和 「本地主機/ MyWeb即可/ index.php文件/測試/ get_ch01/10」 的網址是造成此頁面

{ 
   "success": true, 
   "results": 10, 
   "data": [{ 
         "date_time": "5/12/2012 13:13:33", 
         "chart_data": "3.5" 
      }, 
      { 
         "date_time": "5/12/2012 13:13:34", 
         "chart_data": "0.0" 
      }, 
      { 
         "date_time": "5/12/2012 13:13:35", 
         "chart_data": "3.5" 
      }, 
      { 
         "date_time": "5/12/2012 13:13:36", 
         "chart_data": "0.0" 
      }, 
      { 
         "date_time": "5/12/2012 13:13:4", 
         "chart_data": "0.0" 
      }, 
      { 
         "date_time": "5/12/2012 13:13:5", 
         "chart_data": "3.5" 
      }, 
      { 
         "date_time": "5/12/2012 13:13:6", 
         "chart_data": "0.0" 
      }, 
      { 
         "date_time": "5/12/2012 13:13:7", 
         "chart_data": "3.5" 
      }, 
      { 
         "date_time": "5/12/2012 13:13:8", 
         "chart_data": "0.0" 
      }, 
      { 
         "date_time": "5/12/2012 13:13:9", 
         "chart_data": "3.5" 
      } 
   ] 
} 

上,但是當我」米執行所

console.log(ch01_store.getCount()); 

日誌顯示零 和我試圖填充它在GridPanel中,結果仍然是空的,誰能幫助我?

+0

1.你在控制檯中看到數據是如何請求和檢索? 2.嘗試添加'sucessProperty:'success''但是應該是默認值 – sha

+0

@sha:我沒有在JsonStore文檔上看到successProperty配置,我試過它並且仍然不起作用 – g03r03

+0

你在網絡流量中看到了怎麼樣存儲數據被檢索? – sha

回答

0

設置代理服務器這樣,並嘗試:

proxy: { 
    type: 'ajax', 
    reader: { 
     type: 'json', 
     root: 'xxxxxx' 
     } 
} 
相關問題