1. #1
    Sencha User attu's Avatar
    Join Date
    Aug 2008
    Location
    Madrid, Spain
    Posts
    95
    Vote Rating
    0
    attu is on a distinguished road

      0  

    Default Doubt about JsonStore

    Doubt about JsonStore


    Hello!

    I've got a doubt about JsonStore. Is there any way to keep data in the store after load? I need to operate with the store but after load, the information seems to be disappeared .

    What am i doing wrong? Am i loosing any config. option?

    Thanks in advance!
    People won't be people when they hear this sound, that's been glowing in the dark, at the edge of town. People won't be people, no, the people won't be people when they hear this sound. Won't you show me what begins at the edge of town. The singer is a crook Woah-ay-oh! The kitchen is the cook Woah-ay-oh! The scissors are the barbers Woah-ay-oh! The singer is a crook Woah-ay-oh! The chorus, full of actors Woah-ay-oh! The chorus doesn't matter!

  2. #2
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    91
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    Load is asynchronous! You have to wait for the server to respond before you can access the data.

    You can do that by using a load event handler or the load method callback.

  3. #3
    Sencha User attu's Avatar
    Join Date
    Aug 2008
    Location
    Madrid, Spain
    Posts
    95
    Vote Rating
    0
    attu is on a distinguished road

      0  

    Default


    Uhm... I know that, but i'd like to keep data in the store after load event... I can access to data 1 minute after maybe...

    Thanks Condor!
    People won't be people when they hear this sound, that's been glowing in the dark, at the edge of town. People won't be people, no, the people won't be people when they hear this sound. Won't you show me what begins at the edge of town. The singer is a crook Woah-ay-oh! The kitchen is the cook Woah-ay-oh! The scissors are the barbers Woah-ay-oh! The singer is a crook Woah-ay-oh! The chorus, full of actors Woah-ay-oh! The chorus doesn't matter!

  4. #4
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    91
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    Data in a store doesn't magically disappear. Are you sure you are not clearing the store?

    Maybe you should post some code of what you are actually trying to do...

  5. #5
    Sencha User attu's Avatar
    Join Date
    Aug 2008
    Location
    Madrid, Spain
    Posts
    95
    Vote Rating
    0
    attu is on a distinguished road

      0  

    Default


    Ok .

    This is the situation (a little bit complicated!):

    i've got a TabPanel with some items (a ComboBox and TextFields and Store) and an EditorGridPanel with data. Depending on the rows of the EditorGridPanel, the panel's store changes.

    When i load the window i load the store. onLoad, i can see items in the store, but afterload, store seems to be empty.

    This is the code:
    Code:
    var tabPanelFianzas = Ext.extend(Ext.TabPanel,{
        onRender: function() {
            tabPanelFianzas.superclass.onRender.apply(this, arguments);
        },
        height: 140,
        activeTab: 0,
        radio: null,
        frame: true,
        border: false,
        cargarFianza: function(empresa){
            if(obj.getCount() > '0'){
                this.setCampos(empresa);
            }else{
                var fianza = this.store.recordType;
                var f = new fianza({
                    idFianza: null,
                    empresa: '',
                    importeFP: null,
                    fechaSolicitudFP: null,
                    bancoFP: null,
                    polizaFP: null
                });
                this.store.insert(this.store.getCount(), f);
            }
        },
        addCampo: function(campo, valor){
            var i=this.store.find('empresa',Ext.getCmp('comboFianzas').getValue());
            var record = this.store.getAt(i);
            record.set(campo,valor); 
        },
        setCampos: function(empresa){
            var i=this.store.find('empresa',empresa);
            Ext.getCmp('importeFP').setValue(this.store.getAt(i).data.importeFP);
            Ext.getCmp('fechaSolicitudFP').setValue(this.store.getAt(i).data.fechaSolicitudFP);
            Ext.getCmp('bancoFP').setValue(this.store.getAt(i).data.bancoFP);
            Ext.getCmp('polizaFP').setValue(this.store.getAt(i).data.polizaFP);
            Ext.getCmp('fechaFianza').setValue(this.store.getAt(i).data.fechaFianza);
            Ext.getCmp('checkFianza').setValue(this.store.getAt(i).data.checkFianza);
        },
        store: new Ext.data.JsonStore({
            url: '../napp/Fianzas/get-fianzas-oferta',
            root: 'filas',
            autoLoad: true,
            totalProperty: 'total',
            fields: ['idFianza','empresa','importeFP', 'fechaSolicitudFP', 
                'bancoFP', 'polizaFP', 'fechaFianza', 'checkFianza'],
            listeners: {
                load: function(obj){
                    console.log(obj); // If i do it here, i see data.
                    if(obj.getCount() > 0){
                        Ext.getCmp('importeFP').setValue(obj.getAt(0).data.importeFP);
                        Ext.getCmp('fechaSolicitudFP').setValue(obj.getAt(0).data.fechaSolicitudFP);
                        Ext.getCmp('bancoFP').setValue(obj.getAt(0).data.bancoFP);
                        Ext.getCmp('polizaFP').setValue(obj.getAt(0).data.polizaFP);
                        Ext.getCmp('fechaFianza').setValue(obj.getAt(0).data.fechaFianza);
                        Ext.getCmp('checkFianza').setValue(obj.getAt(0).data.checkFianza);
                    }
                }
            }
        }),
        initComponent: function () {
            Ext.apply(this, {
                items:[{
                    title: 'Sumario Fianzas',
                    frame: true
                },{
                    title: 'Añadir Fianza',
                    frame: true,
                    layout: 'form',
                    items:[{
                        xtype: 'combo',
                        store: this.store,
                         id: 'comboFianzas',
                        displayField: 'empresa',
                        fieldLabel: 'Empresa',
                        mode: 'local',
                        triggerAction: 'all',
                        anchor: '30%',
                        listeners:{
                            select: function(){
                                this.setCampos(Ext.getCmp('comboFianzas').getValue());
                            },
                            scope: this
                        }
                    },{
                        ... ITEMS ...
                    }]
                }]
            });
            
            tabPanelFianzas.superclass.initComponent.apply(this, arguments);
        }
    });
    
    Ext.reg('tabPanelFianzas', tabPanelFianzas);
    Combo's store is the same than JsonStore of the TabPanel. When i try to get info from the console, store is empty (after load).

    Thanks!
    People won't be people when they hear this sound, that's been glowing in the dark, at the edge of town. People won't be people, no, the people won't be people when they hear this sound. Won't you show me what begins at the edge of town. The singer is a crook Woah-ay-oh! The kitchen is the cook Woah-ay-oh! The scissors are the barbers Woah-ay-oh! The singer is a crook Woah-ay-oh! The chorus, full of actors Woah-ay-oh! The chorus doesn't matter!

  6. #6
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    91
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    What exactly are you entering on the console?

  7. #7
    Sencha User
    Join Date
    Mar 2008
    Location
    Brazil
    Posts
    73
    Vote Rating
    5
    fabio.parra is on a distinguished road

      0  

    Default


    Hey...see this screencast about Ext.getCmp

  8. #8
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    91
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    So you are doing something like:
    Code:
    console.log(Ext.getCmp('comboFianzas').store.getCount());

  9. #9
    Sencha User attu's Avatar
    Join Date
    Aug 2008
    Location
    Madrid, Spain
    Posts
    95
    Vote Rating
    0
    attu is on a distinguished road

      0  

    Default


    Yes, i watched that screencast . I'm trying to avoid the use of Ext.getCmp. Anyway, that's just a test .

    Yes, i write something like that. But, i'm really sorry because (i don't know why) it works rightnow... Thanks for your help .
    People won't be people when they hear this sound, that's been glowing in the dark, at the edge of town. People won't be people, no, the people won't be people when they hear this sound. Won't you show me what begins at the edge of town. The singer is a crook Woah-ay-oh! The kitchen is the cook Woah-ay-oh! The scissors are the barbers Woah-ay-oh! The singer is a crook Woah-ay-oh! The chorus, full of actors Woah-ay-oh! The chorus doesn't matter!

Similar Threads

  1. Doubt on Rowexpander
    By ssssuresh2007 in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 11 Jun 2010, 3:44 AM
  2. Doubt in the ExtJs
    By phanikumar121 in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 3 Mar 2010, 7:24 AM
  3. Doubt about license
    By Zener in forum Community Discussion
    Replies: 8
    Last Post: 14 Feb 2009, 4:15 PM

Thread Participants: 2