Hi, i have a problem saving data in a model type HasMany, this is my code:
Model:
Code:
Ext.regModel('pedidoModel',{ idProperty: 'id',
fields: [
{name: 'id', type: 'int'},
{name: 'ClaseDocumento', type: 'string'},
{name: 'Referencia', type: 'string'},
{name: 'CodigoCliente', type: 'string'}
],
associations: [
{type: 'hasMany', model: 'interlocutoresModel', name: 'interlocutores'}
],
proxy:
{
type: 'localstorage',
id: 'pedidoStore'
}
});
Ext.regModel ('interlocutoresModel', {
fields: [
{name: 'pedidoModel_id', type: 'int'},
{name: 'Funcion', type: 'string' },
{name: 'Codigo', type: 'string'}
],
associations: [
{type: 'belongsTo', model: 'pedidoModel'}
],
proxy: {
type: 'localstorage',
id: 'interlocutores'
}
});
Code:
Code:
var currentDoc = interlocutoresView.store.last();
var interStore = currentDoc.interlocutores();
var Funcion = panel1.getValues().Funcion;
var Codigo = panel1.getValues().Codigo;
var inter1 = Ext.ModelMgr.create(
{'Funcion':Funcion,'Codigo':Codigo},
'interlocutoresModel'
);
panel1.load(inter1);
var currentInter = panel1.getRecord();
interStore.add(currentInter);
interStore.sync();
console.log(interStore.data.items);
I can get the item saved like I see in the console, but when I refresh the page, the data is gone.
What I can do? Is anything wrong in my code?
Thanks in advance.