View Full Version : Extjs 4.2.1 store autosync does not refresh grid after add new record

29 Apr 2014, 6:10 AM
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:

Ext.define('siccar.store.storeListaAcreditados', {
extend: 'Ext.data.Store',

requires: [

constructor: function(cfg) {
var me = this;
cfg = cfg || {};
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

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)]);

29 Apr 2014, 11:08 AM
How do you add the record?

29 Apr 2014, 12:30 PM
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

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
} else{ //De Lo contrario, si la accion fue para agregar, se inserta un registro
record = Ext.create(MVCModel);


29 Apr 2014, 2:31 PM
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. :D

29 Apr 2014, 2:56 PM
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.:D