2011-10-19 50 views
0

我有問題從JSON存儲加載數據到EXT網格。以下是代碼:如何從JSONStore中加載extJS網格中的數據?

var store = new Ext.data.JsonStore({ 
     root: 'rates', 
     autoLoad=true, 
     fields: ['mainid','Country'], 
     proxy : new Ext.data.HttpProxy({ 
       method: 'GET', 
       url: '/projectLink/gridData.php' 
      }) 
    }); 

    var grid = Ext.create('Ext.grid.Panel',{ 
        renderTo: 'grid-rates', 
        width:700, 
        height:500, 
        title:"Country", 
        store:store, 
        columns:[ 
           {id: 'mainid', header: "mainid", width: 200, sortable: true, dataIndex: 'mainid'}, 
           {id: 'Country', header: "Country", width: 200, sortable: true, dataIndex: 'Country'} 
          ] 

       }); 

的JSON店要充滿,因爲它發出請求,服務器和數據發回,但電網是從來沒有填充:(缺少了什麼

以下是我的JSON?米使用:

{"count":"18239", 
"rates":[ 
{"mainid":"75966","Country":"Afghanistan Cellular-AT"}, 
{"mainid":"75967","Country":"Afghanistan Cellular-AWCC"}, 
{"mainid":"75968","Country":"Afghanistan Cellular-Areeba"}, 
{"mainid":"75969","Country":"Afghanistan Cellular-Etisalat"}, 
{"mainid":"75970","Country":"Afghanistan Cellular-Others"}, 
{"mainid":"75971","Country":"Afghanistan Cellular-Roshan"}, 
{"mainid":"75972","Country":"Albania"}, 
{"mainid":"75973","Country":"Albania Cellular-AMC"}, 
{"mainid":"75974","Country":"Albania Cellular-Eagle"}, 
{"mainid":"75975","Country":"Albania Cellular-Plus"} 
]} 

請幫

+0

有哪些你得到任何錯誤?發佈錯誤消息,如果有的話,這將有所幫助。 – netemp

回答

2

使用Ext.data.Store代替JsonStore,在4.0.2a
還測試了!我不能在文檔

找到JsonStore試試這個:

var store = new Ext.data.Store({ 
    fields:['mainid','Country'], 
    proxy: { 
     type: 'ajax', 
     url : '/projectLink/gridData.php', 
     reader: { 
      type: 'json', 
      root: 'rates', 
      totalProperty : "count" 
     } 
    }, 
    autoLoad : true 
}); 
2

我不知道這是否是問題,但在配置autoLoad是錯誤的。

您有:autoLoad=true

它應該是:autoLoad : true