Results 1 to 2 of 2

Thread: create grid from json url

  1. #1

    Default create grid from json url

    Hi all,

    May be this is banal, but I don't understand how to populate a Grid starting from the json response returnet from this URL...

    http://sampleserver1.arcgisonline.co...ields=&f=pjson

    Thanks a lot in advance!

  2. #2

    Default

    I'm managing to solve the problem.
    I obtain the correct number of rows... but they are empty.
    I can imagine there's something wrong with my JsonReader configuration, but I don't understand exactly what.

    I really appreciate any suggestion, thanks guys...

    Code:
    Ext.onReady(function() {
            
                //URL var
                var URL = "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5/query?where=SUB_REGION+%3D+%27Mountain%27&returnGeometry=false&outFields=ObjectID,SUB_REGION&f=json"
                
                
                /*GRID CONSTRUCTION
                ************************/
            
                //Data returned from the REST service
             
                //Data Store
                var ds = new Ext.data.Store({
                    proxy: new Ext.data.ScriptTagProxy({url:URL, method:'GET'}), 
                    reader: new Ext.data.JsonReader({root:'features', id:'ObjectID'}, [
                        {name: 'ObjectID'},
                        {name: 'STATE_NAME'},
                        {name: 'SUB_REGION'}
                    ])
                });
                ds.load();
     
                //Column Model
                var colModel = new Ext.grid.ColumnModel([
                    {header: "ID", width: 100, sortable: true, dataIndex: 'ObjectID'},
                    {header: "State", width: 100, sortable: true, dataIndex: 'STATE_NAME'},
                    {header: "Sub Region", width: 100, sortable: true, dataIndex: 'SUB_REGION'}
                ]);
             
                //Grid
                var grid = new Ext.grid.GridPanel({
                    el: 'grid-example', 
                    ds: ds, 
                    cm: colModel,
                    height:150,
                    autoScroll:true
                });
                
                grid.render();
                grid.getSelectionModel().selectFirstRow();
                Ext.get('grid-example').show();
                
            });

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •