Results 1 to 3 of 3

Thread: Load Remote Web Service JSON string in a GRID

  1. #1
    Sencha User alexbariv's Avatar
    Join Date
    May 2009
    Location
    Mrida, Venezuela
    Posts
    67

    Question Load Remote Web Service JSON string in a GRID

    Hi.

    I need a little help here because everything its rendering perfect except the data.

    So i have this JSON string in a remote server:

    Code:
    {
     success:true,
     rows:[
              {"cod_perfil":1,"0":1,"nombre":"Administrador","1":"Administrador"},
              {"cod_perfil":3,"0":3,"nombre":"Invitado","1":"Invitado"}
            ]
    }
    The idea its to show all the records in a grid like this:

    Code:
    myApp.ListarPerfiles = Ext.extend(Ext.grid.GridPanel, { 
    
        initComponent : function() {
    
            Ext.apply(this, {
                frame  : true,
                title  : 'Perfiles',
                height : 200,
                width  : 500,
                viewConfig:{forceFit:true}
            });
            
            this.store = new Ext.data.JsonStore({
                proxy  : new Ext.data.HttpProxy({ 
                    url    : 'http://192.168.21.1:8080/apps/movilsystem/air/perfiles.php',
                    method : 'get'
                }),
                reader : new Ext.data.JsonReader({
                    root   : 'rows',
                    fields : [
                        {name:'cod_perfil', type:'integer'},
                        'nombre'
                    ]
                })
            });
            
            this.columns = [{
                id        : 'nombre',
                header    : 'Nombre', 
                dataIndex : 'nombre'
            }];
            
            myApp.ListarPerfiles.superclass.initComponent.call(this);
            
        },
        onRender:function() {
    
            myApp.ListarPerfiles.superclass.onRender.apply(this, arguments);
            this.store.load();
            
        }
    });
    
    Ext.reg('ListarPerfiles', myApp.ListarPerfiles);
    I'm reading a lot of samples about this in the web, but still cant get the data loading.

    I'm only needing the field "nombre" of the json response.

    What i have wrong???


    Thanks in advance!


  2. #2

    Default

    I think the fields in your reader need to match the fields in the JSON even if you don't use them.

  3. #3
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    Alex. Google "Same Origin Policy"

Posting Permissions

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