I have following model and store.
Model:
Ext.define('TruckTask.model.Company', {
extend: 'Ext.data.Model',
idProperty: 'id',
fields: [
{name: 'id', type: 'int', defaultValue: null},
{name: 'name', type: 'string'},
{name: 'site', type: 'string'},
{name: 'createdDate', type: 'date',
convert: function(rawValue, model) {
var intDate = parseInt(rawValue);
if(intDate > 0){
return Ext.util.Format.date(new Date(intDate), 'd.m.Y');
}
if(typeof(rawValue) == 'object'){
return rawValue;
}
}
},
{name: 'langId', type: 'int'}
]
});
Store:
Ext.define('TruckTask.store.Company', {
extend: 'Ext.data.Store',
requires : [
'TruckTask.model.Company',
'TruckTask.config.SecureRestProxy'
],
alias: 'store.company',
storeId: 'company',
model : 'TruckTask.model.Company',
autoLoad: true,
autoSync: true,
proxy: {
type: 'secure-rest',
reader: {
type: 'json'
},
writer: {
type: 'json'
},
api: {
read: '/api/company',
create: '/api/company',
update: '/api/company',
destroy: '/api/company'
}
}
});
I use grid panel for list of this models. But creation of new model I make through another form.
In grid I define store:
store: {
type: 'company'
},
and form's submit handler has implementation:
var record = this.getViewModel().get('rec');
var companyStore = Ext.data.StoreManager.lookup('company');
companyStore.add(record);
So the record appears in grid panel immediately, but without createdDate field value. This value comes from server response.
How can I update this record in grid panel when I get server response?
I think you will find this answer useful. Implement the onCreateRecords on your store and set whatever needs to be set after new records has been created and saved.