1. #1
    Sencha User
    Join Date
    Feb 2010
    Posts
    356
    Answers
    15
    Vote Rating
    4
    maneljn is on a distinguished road

      1  

    Default Answered: extjs 4.2 store.sync() don't refresh returned data anymore ?

    Answered: extjs 4.2 store.sync() don't refresh returned data anymore ?


    With extjs 4.1.1.a when i sync() a store, and then in php i return json data of refreshed record, the model record and the grid is automatically refreshed.

    Now i am upgrading to ext v4.2 and this doesn't work anymore.
    I have not changed nothing in my source code

    Is it normal ?
    -------------------
    Manel Juàrez

  2. Quote Originally Posted by maneljn View Post
    I could not solve it.
    I continue using v4.1.1
    If you have good news for me, it would be appreciated. ;-)

    Manel
    Problem is, when the data have to get back to extjs, always the id comes empty, i set in the reader idProperty=idsocio and anything seems works, i do not wanna downgrade to 4.1.1 , if i know how to resolve this case, you gonna be the first to know about how to fix this issue.

  3. #2
    Sencha User
    Join Date
    Feb 2010
    Posts
    356
    Answers
    15
    Vote Rating
    4
    maneljn is on a distinguished road

      0  

    Default


    sorry i correct the question.

    In this problem i do a model.save() (not a store.sync()) using direct proxy api update function
    And the returned data looks like this:

    Code:
    {"type":"rpc","tid":10,"action":"esicontactos_contactos","method":"updateContacto","result":{"success":true,"data":[{"cto_id":"63","cto_guid":"5050a5317736a","cto_tipo":"E","cto_sexo":"","cto_nombre_propio":"","cto_apellidos":"","cto_nombre_fiscal":"ACME INC.","cto_nombre_com":"","cto_nif":"","cto_nacimiento":null,"cto_idioma":"es_ES","cto_observaciones":"observa\nPEPITOR\nMAR\u00cda\ndf \nvs\nvs\nfv s\nfv \nsfv\n sdfv\n sv\n sfv\ns df\nv sd\nfv s\nf s\nf sd\nfv sd\nf sd\nfv \n","cto_activo":"1","cto_usralta_id":"1","cto_fechaalta":"2012-09-12 17:07:29","cto_usrmod_id":"1","cto_fechamod":"2013-04-11 16:16:14","dir_id":"50","dir_guid":"5050a53177b63","dir_contacto_id":"63","dir_fiscal":"1","dir_alias":"","dir_via":"PL","dir_nom":"CREU DE LA M\u00c0","dir_num":"1","dir_esc":"2","dir_pis":"3","dir_pue":"4","dir_direc1":"PL CREU DE LA M\u00c0 1 2 3 4","dir_direc2":"","dir_pos":"08001","dir_pob":"BARCELONA","dir_pro":"","dir_pais_iso3":"ESP","dir_tel1":"","dir_tel2":"","dir_fax":"","dir_email":"","dir_web":"","dir_activo":"1","dir_usralta_id":"1","dir_fechaalta":"2012-09-12 17:07:29","dir_usrmod_id":"1","dir_fechamod":"2013-04-11 16:16:14","cto_edad":null,"cto_gruposcontactos_asignados":[0],"cto_esUsuario":"0","cto_usralta_nombre":"JU\u00c0REZ NICOLAU, MANEL","cto_usrmod_nombre":"JU\u00c0REZ NICOLAU, MANEL"}],"total":"1"}}
    The model
    Code:
    //@charset UTF-8
    
    // Modelo de datos para los contactos
    Ext.define('esicontactos.model.contacto', {
        extend: 'Ext.data.Model',
        
        idProperty: 'cto_id',
        fields: [
            { name: 'cto_id',                     type: 'integer' },
            { name: 'cto_guid',                     type: 'string' },
            { name: 'cto_tipo',                     type: 'string' },
            { name: 'cto_sexo',                     type: 'string' },
            { name: 'cto_nombre_propio',         type: 'string' },
            { name: 'cto_apellidos',             type: 'string' },
            { name: 'cto_nombre_fiscal',         type: 'string' },
            { name: 'cto_nombre_com',            type: 'string' },
            { name: 'cto_nif',                    type: 'string' },
            { name: 'cto_nacimiento',            type: 'date', dateFormat: 'Y-m-d' },
            { name: 'cto_idioma',                type: 'string' },
            { name: 'cto_edad',                 type: 'integer' },
            { name: 'cto_observaciones',        type: 'string' },
            { name: 'cto_activo',                type: 'boolean' },
            { name: 'cto_esUsuario',            type: 'boolean', persist: false },
            
            // Vienen y van los ids de grupos asisnados en un  array de integers
            { name: 'cto_gruposcontactos_asignados', type: 'auto' },        
    
            // Direccion fiscal
            { name: 'dir_via',                type: 'string' },
            { name: 'dir_nom',                type: 'string' },
            { name: 'dir_num',                type: 'integer' },
            { name: 'dir_esc',                type: 'string' },
            { name: 'dir_pis',                type: 'string' },
            { name: 'dir_pue',                type: 'string' },
            { name: 'dir_direc1',            type: 'string' },
            { name: 'dir_direc2',            type: 'string' },
            { name: 'dir_pos',                type: 'string' },
            { name: 'dir_pob',                type: 'string' },
            { name: 'dir_pro',                type: 'string' },
            { name: 'dir_pais_iso3',        type: 'string' },
            { name: 'dir_tel1',                type: 'string' },
            { name: 'dir_tel2',                type: 'string' },
            { name: 'dir_fax',                type: 'string' },
            { name: 'dir_email',            type: 'string' },
            { name: 'dir_web',                type: 'string' },
            
            { name: 'cto_usralta_id',            type: 'integer', persist: false },
            { name: 'cto_fechaalta',             type: 'date', dateFormat: 'Y-m-d H:i:s', persist: false },    
            { name: 'cto_usrmod_id',            type: 'integer', persist: false },
            { name: 'cto_fechamod',             type: 'date', dateFormat: 'Y-m-d H:i:s' },        // Este campo se usará para el aviso de sobreescritura en concurrencia (2 usuarios grabando en el mismo registro a la vez)
            { name: 'cto_usralta_nombre',         type: 'string', persist: false },
            { name: 'cto_usrmod_nombre',         type: 'string', persist: false }
        ]
        
    });
    The store
    Code:
    Ext.define('esicontactos.store.contactos', {
        extend: 'Ext.data.Store',
    
        requires: [
            'esicontactos.model.contacto'
        ],
    
        constructor: function(cfg) {
            var me = this;
            cfg = cfg || {};
            me.callParent([Ext.apply({
                autoLoad: false,
                autoSync: false,
                buffered: false,
                model: 'esicontactos.model.contacto',
                remoteSort: true,
                remoteFilter: true,
                pageSize: 50,
                proxy: {
                    type: 'direct',
                    batchActions: false,
                    paramAsHash: true,
                    extraParams: {  
                        buscar: null
                    },
                    api: {
                        read: Ext.esicontactosDirect.esicontactos_contactos.getContactos,
                        create: Ext.esicontactosDirect.esicontactos_contactos.createContacto,
                        update: Ext.esicontactosDirect.esicontactos_contactos.updateContacto,
                        destroy: Ext.esicontactosDirect.esicontactos_contactos.destroyContacto
                    },
                    reader: {
                        type: 'json',
                        root: 'data',
                        idProperty: 'cto_id',
                        totalProperty: 'total',
                        successProperty: 'success',
                        messageProperty : 'message'                    
                    }
                }
            }, cfg)]);
        }
    
            
    });
    The returned data is not refreshed in the model record.
    -------------------
    Manel Juàrez

  4. #3
    Sencha User
    Join Date
    Oct 2012
    Posts
    5
    Vote Rating
    0
    alsid is on a distinguished road

      0  

    Default


    Can you show the code which inserts new record into the store before calling save() or sync() functions?

    I had similar issue with ExtJs 4.2. I was getting an empty record with reader, modifying it (filling all the fields) and than calling sync() method expecting that fields which were not filled would be updated. Particularly I was expecting that ID field will be populated with value generated by server. At least it was working like that with prior versions of ExtJs.

    With ExtJs 4.2 I've got a problem. Returned data was OK but id field of the record wasn't refreshed. The problem appeared to be with the sequence of sync operations which was generated by proxy object. In my scenario proxy was generating an update operation which assumes that record has normal id. I solved my issue by setting id property with setId() method of the model to null or empty value. After that proxy started generating insert operation which was right. I know that the whole thing about such way of inserting record is not good but the problem was not in my code so I decided not to change it a lot.

    I think your problem is also related to Ids.
    Hope it will help.

  5. #4
    Sencha User
    Join Date
    Oct 2011
    Posts
    35
    Vote Rating
    2
    ejerrywest is on a distinguished road

      0  

    Default


    I had the same problem, that appeared in 4.2.

    Found that I was calling "store.commitChanges" before I was calling "store.sync". When I took that out it handled the problem

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

      0  

    Default same problem with extjs 4.2.1 but not with 4.1.1

    same problem with extjs 4.2.1 but not with 4.1.1


    Hi, did you resolve the issue? because i'm in the same problem my store have autosync=true but when i add a new record my grid does not refresh.

    Working at the same time with extjs 4.1.1 with another project all works perfectly, but extjs 4.2.1 seems to have a bug.

  7. #6
    Sencha User
    Join Date
    Feb 2010
    Posts
    356
    Answers
    15
    Vote Rating
    4
    maneljn is on a distinguished road

      0  

    Default


    I could not solve it.
    I continue using v4.1.1
    If you have good news for me, it would be appreciated. ;-)

    Manel
    -------------------
    Manel Juàrez

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

      0  

    Default


    Quote Originally Posted by maneljn View Post
    I could not solve it.
    I continue using v4.1.1
    If you have good news for me, it would be appreciated. ;-)

    Manel
    Problem is, when the data have to get back to extjs, always the id comes empty, i set in the reader idProperty=idsocio and anything seems works, i do not wanna downgrade to 4.1.1 , if i know how to resolve this case, you gonna be the first to know about how to fix this issue.

  9. #8
    Sencha User
    Join Date
    Feb 2010
    Posts
    356
    Answers
    15
    Vote Rating
    4
    maneljn is on a distinguished road

      0  

    Default


    Can you post your piece of code ?
    -------------------
    Manel Juàrez

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

      0  

    Default


    Quote Originally Posted by maneljn View Post
    Can you post your piece of code ?
    Sure:
    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({
                autoSave: true,
                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)]);
        }
    });
    greetings

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

      0  

    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.