0

I use the following Ext function for bind the values in ext grid from the json array.I get the the json array from the URL.It will work Fine,which means i get the values.And my problem is If i try to bind the values in Extjs grid i cant able to add the json array values in that grid.How to solve this?

Ext.onReady(function(){

    var proxy=new Ext.data.HttpProxy({url:'http://someurl'});

    var reader=new Ext.data.JsonReader({},[
          {name: 'User_Id', mapping: 'User_Id'},
          {name: 'First_Name', mapping: 'First_Name'},            
          {name: 'Last_Name', mapping: 'Last_Name'}, 
          {name: 'Notes', mapping: 'Notes'} 
     ]);
     //alert(reader);
     var store=new Ext.data.Store(    {
         proxy:proxy,
         reader:reader
     });

    store.load();


    // create the grid
    var grid = new Ext.grid.GridPanel({
        store: store,
        columns: [
            {header: "User_Id", width: 60, dataIndex: 'User_Id', sortable: true},
            {header: "First_Name", width: 60, dataIndex: 'First_Name', sortable: true},
            {header: "Last_Name", width: 60, dataIndex: 'Last_Name', sortable: true},
                           {header: "Notes", width:80, dataIndex: 'Notes', sortable: true}

        ],
        renderTo:'example-grid',
        width:2000,
        height:1000
    });

});
sra
  • 23,820
  • 7
  • 55
  • 89
User
  • 1,644
  • 10
  • 40
  • 64

2 Answers2

0

Can you post the JSON response that you are getting from "http://someurl?"

I hope your JSON response has key value pairs for the following keys 'User_Id', 'First_Name','Last_Name','Notes'.

Uzair
  • 135
  • 2
  • 14
  • { "ResponseCode": "111", "ResponseMessage": "Success", "Values": [ { "User_Id": 1, "First_Name": "abcd", "Last_Name": "efgh", "Notes": null } ] } – User Aug 28 '12 at 06:17
  • You would need to set `root: 'Values'` in your store's config. – Uzair Aug 28 '12 at 06:27
0

ExtJS expects a json response like this:

{
    "ResponseCode": "111",
    "success": true,
    "total": 1,
    "data": [{
        "User_Id": 1,
        "First_Name": "abcd",
        "Last_Name": "efgh",
        "Notes": null
    }]
}​
Johan Haest
  • 4,391
  • 28
  • 37