2011-10-19 45 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