1. #1
    Sencha User
    Join Date
    Dec 2013
    Posts
    17
    Vote Rating
    1
    Answers
    1
    beticocorzo is on a distinguished road

      0  

    Default Answered: Extjs 4.2.1 store autosync does not refresh grid after add new record

    Answered: Extjs 4.2.1 store autosync does not refresh grid after add new record


    problem with extjs 4.2.1 but not with 4.1.1

    Hi all, i have a problem with my store that have autosync=true, i mean, when i add a new record my grid does not refresh.

    i'm working at the same time with extjs 4.1.1 with another project and all works perfectly, but extjs 4.2.1 does not let me refresh my grid. this is a 4.2.1 bug?

    my code:
    Code:
    Ext.define('siccar.store.storeListaAcreditados', {
        extend: 'Ext.data.Store',
    
    
        requires: [
            'siccar.model.modelListaAcreditados',
            'Ext.data.proxy.Ajax',
            'Ext.data.reader.Json',
            'Ext.data.writer.Json'
        ],
    
    
        constructor: function(cfg) {
            var me = this;
            cfg = cfg || {};
            me.callParent([Ext.apply({
                autoLoad: false,
                autoSync: true,
                model: 'siccar.model.modelListaAcreditados',
                storeId: 'storeListaAcreditados',
                proxy: {
                    type: 'ajax',
                    afterRequest: function(request, success) {
                        if (request.action == 'create')
                        {
    
    
                            var jsonMsg = (request.operation.params.data.idsocio);
                            var vMsg=jsonMsg.msg; //msg :viene del Archivo PHP
                            Ext.Msg.alert('Actualizado',vMsg);
    
    
                        }
                    },
                    actionMethods: {
                        read: 'POST'
                    },
                    api: {
                        create: 'controller_acreditados/insertAcreditados',
                        read: 'controller_acreditados/readListaAcreditados',
                        update: 'controller_acreditados/updateAcreditados',
                        destroy: 'controller_acreditados/deleteAcreditados'
                    },
                    reader: {
                        type: 'json',
                        idProperty: 'idsocio',
                        root: 'data'
                    },
                    writer: {
                        type: 'json',
                        dateFormat: 'Y-m-d',
                        encode: true,
                        root: 'data'
                    }
                }
            }, cfg)]);
        }


  2. Did you check your idPropierty in your reader? this should be the same as the result or your column id from your database, (in your case idsocio), another problem is when the data result some times comes with error, i mean, check your json insert result with firebug if you have some bad insert or something else, i was with the same problem and i realized that the problem was the invalid JSON String or etc.

  3. #2
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,561
    Vote Rating
    384
    Answers
    488
    jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future

      0  

    Default


    How do you add the record?
    Jozef Sakalos, aka Saki

    Education, extensions and services for developers at new http://extjs.eu
    News: Grid Search Plugin, ExtJS 5 Complex Data Binding using MVVM


  4. #3
    Sencha User
    Join Date
    Dec 2013
    Posts
    17
    Vote Rating
    1
    Answers
    1
    beticocorzo is on a distinguished road

      0  

    Default


    Quote Originally Posted by jsakalos View Post
    How do you add the record?
    Hi jsakalos thanks, here is my code:
    Note: storeName is the name of my store
    MVCModel is the name of my model.
    as i commented before, after insert my grid no refresh with the new data ultil i click refresh. The same code works perfectly with 4.1.1
    Code:
     var win    = button.up('window'),
         form   = win.down('form'),
         record = form.getRecord(),
         values = form.getValues();
         store  = Ext.data.StoreManager.lookup(StoreName);
    if (values.id > 0){ //Si Hay algun Valor, entra en Modo de Actualizacion
        record.set(values);
    } else{ //De Lo contrario, si la accion fue para agregar, se inserta un registro
        record = Ext.create(MVCModel);
        record.set(values);
        store.add(record);
        
        
    }
    win.close();

  5. #4
    Sencha User
    Join Date
    Nov 2010
    Location
    Villaflores,Chiapas,Mexico
    Posts
    90
    Vote Rating
    2
    Answers
    8
    icebergdelphi is on a distinguished road

      2  

    Default


    Did you check your idPropierty in your reader? this should be the same as the result or your column id from your database, (in your case idsocio), another problem is when the data result some times comes with error, i mean, check your json insert result with firebug if you have some bad insert or something else, i was with the same problem and i realized that the problem was the invalid JSON String or etc.

  6. #5
    Sencha User
    Join Date
    Dec 2013
    Posts
    17
    Vote Rating
    1
    Answers
    1
    beticocorzo is on a distinguished road

      1  

    Default


    yep you are right icebergdelphi, i was checking with firefug and the problem seen to be a field date of my form and if i let this field empty and click save, the extjs raw grid appears with phantom record, and in my json result : Ext.Error: You're trying to decode an invalid JSON String, but if i do not let the field date empty the refresh grid after insert works perfectly. Thanks a lot.

Thread Participants: 2