Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: reader is loaded but store empty ?

  1. #1
    Ext User
    Join Date
    May 2008
    Posts
    71

    Default reader is loaded but store empty ?

    Hi,

    What can be happening if my store is loaded but empty??
    In firebug I see the reader has the response loaded ok.
    Json is also fine as I've checked on JSLint.

    Anyone??

  2. #2

    Default

    the json may pas jslint, but that doesnt mean it matches what the reader expects.
    and you havent given us enough information to help with that.

  3. #3
    Ext User
    Join Date
    May 2008
    Posts
    71

    Default

    Thanks Devnull,

    this is the code for my Store:

    Code:
    var reader = new Ext.data.JsonReader({}, [
                   {name: 'Articulo', type: 'string', mapping: 'label'},
                {name: 'Descripcion', type: 'string', mapping: 'descripcion'},
                {name: 'Categoria', type: 'string', mapping: 'categoria'},
                {name: 'Subpartida', type: 'string', mapping: 'subpartida'},
                {name: 'Unidad', type: 'string', mapping: 'unidad'},
                {name: 'Cantidad', type: 'string', mapping: 'cantidad'},
                {name: 'Ultima_mod', type:'date', mapping: 'ult_mod', dateFormat: 'Y-m-d H:i:s'}
        ]);
        
        // create the data store
        var resultStore = new Ext.data.GroupingStore({
            url: 'index.php',
            totalProperty: 'totalRecords',
            root: 'resultadoGrid',
            reader: reader,
            sortInfo:{field: 'Articulo', direction: "ASC"},
            remoteSort: true
        });
    The Json response I get is this:

    ({"totalRecords":4,"resultadoGrid":[{"cuenta_art":"1","recordID":"13","label":"Articulo 001","descripcion":"Articulo de pruebas","cod_categoria":"2","categoria":"MC-Mercadera","subpartida":"12.69.51.23.51","unidad":"500 PIEZAS(PZA),60 TONELADAS(TM),40000 PIES(FT)","cantidad":"500,60,40000","ult_mod":"2008-06-19 15:14:03"},{"cuenta_art":"1","recordID":"14","label":"Articulo 002","descripcion":"Aceites para elaboracion de resinas industriales","cod_categoria":"2","categoria":"MC-Mercadera","subpartida":"12.69.48.72.13","unidad":"150 BARRILES (42 GALON US)(BRR ),300000 LITRO (L ),8000000 ONZAS (OZ )","cantidad":"150,300000,8000000","ult_mod":"2008-06-19 15:14:03"},{"cuenta_art":"1","recordID":"15","label":"Aceite Crudo de Palma","descripcion":"","cod_categoria":"1","categoria":"MP-Materia prima","subpartida":"12.69.48.72.13","unidad":"2000 TONELADAS(TM),2000000 KILOGRAMO(KG)","cantidad":"2000,2000000","ult_mod":"2008-06-19 15:13:52"},{"cuenta_art":"1","recordID":"16","label":"Montacargas","descripcion":"Montacargas utilizado en el proceso de produccion","cod_categoria":"3","categoria":"MQ-Maquinaria","subpartida":"12.69.48.72.13","unidad":"1 UNIDADES(U)","cantidad":"1","ult_mod":"2008-06-19 14:51:43"}]})

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

    Default

    You are not configuring your JsonReader properly. It needs the totalProperty and root.

    http://extjs.com/deploy/dev/docs/?cl...ata.JsonReader

  5. #5
    Ext User
    Join Date
    May 2008
    Posts
    71

    Default

    ohhh, I see, so the totalProperty and root have to go on Reader but not in Store as I had??

    One thing though, I can see the store is loading twice
    I make my store load on a listener from a combo and, on store 'load' listener, I make my grid render and the store loads again.
    Is this ok?

    Thanks Animal as usual

  6. #6
    Sencha User jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364

    Default

    the reader doesn't 'load', it acts as a 'filter' to parse data and properly fill the 'slots' for the records that go into the data store.

  7. #7
    Ext User
    Join Date
    May 2008
    Posts
    71

    Default

    Yes, jgarcia.
    Is the data store what I'm talking about.

    Maybe with the code is better understood:

    Code:
    mycombo.on('select', function(us){
                    win_Choose_Cliente.hide();    
                    resultStore.proxy= new Ext.data.HttpProxy({url: 'index.php?accion=consultarAdmSaldoInventarios&opcionExt=cargaGrid&dpCliente='+this.value});
                    resultStore.load({params: {start:0, limit: 2}});            
       });
    
    //this loads my store correctlly :)
    
    //now here's the listener for the loading of the store where I render my grid
    
    resultStore.on({
    
        'load':{
            fn: function(store, records, options){
                grid.render('menuActions');
                grid.getSelectionModel().selectFirstRow();
    
                //this is for checking on firebug
                console.log('Data Store listener fired (load), arguments:',arguments);
                console.log('Store count = ',store.getCount());
    
            }
            ,scope:this
    
        } 
        });

  8. #8
    Ext User
    Join Date
    May 2008
    Posts
    71

    Default

    Never mind

    I solved the problem not loading the store but directlly rendering the grid on the combo select event

  9. #9
    Sencha User hendricd's Avatar
    Join Date
    Aug 2007
    Location
    Long Island, NY USA
    Posts
    5,966

    Default

    Are you sure about that?

    Do you really want to re-render the grid every time the combo selection changes?
    "be dom-ready..."
    Doug Hendricks

    Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.


    Got Sencha licensing questions? Find out more here.


  10. #10

Page 1 of 2 12 LastLast

Posting Permissions

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