I'm trying to have a combobox on a form to add store doing that I have associated with a grid, but can not get pass the value of the associated models.
I tring make a setter (which I defined) but nothing.
Extjs version is 4.1.
Here you have an example of code to see what you think.
What I do is start object which then fill the form values ??and then do an add to this record store.
I am that which I do not. Thank you very much.
Model:
Ext.define('estacionClinica.model.Peticion', {
extend : 'Ext.data.Model',
fields : [{
name: 'id',
type: 'int'
}..],
associations : [{
type : 'hasOne',
model : 'estacionClinica.model.AmbitoPeticion',
getterName : 'getAmbitoPeticion',
setterName : 'setAmbitoPeticion',
associationKey : 'ambitoPeticion'
associatedName : 'ambitoPeticion'
)]
Store:
Ext.define('estacionClinica.store.Peticion', {
extend : 'Ext.data.Store',
model : 'estacionClinica.model.Peticion',
autoLoad : false,
pageSize : itemsPerPage,
proxy : {
type : 'ajax',
autoSave: false,
api: {
create : 'savePeticion.json',
read: 'recuperarPeticionesByIdPaciente.json',
update : 'updatePeticion.json',
destroy : 'deletePeticion.json'
},
reader: {
type: 'json',
root: 'peticiones',
totalProperty: 'results',
successProperty: 'success',
messageProperty: 'mensaje'
},
writer: {
type: 'json'
//root: 'peticion',
//totalProperty: 'total',
//successProperty: 'success',
//messageProperty: 'message',
//idProperty: 'id'
}
}
});
view: (parte of this)
items: [{
xtype: 'form',
alias : 'widget.addPeticionForm',
id: 'formAddPeticion',
,{
xtype : 'combo',
fieldLabel : 'Caracter Peticion',
name : 'caracterPeticion',
id : 'comboCaracterPeticion',
queryMode : 'local',
valueField : 'id',
displayField: 'nombre',
editable:false,
store: 'CaracterPeticion',
typeAhead: true,
triggerAction: 'all',
forceSelection:true
}
}
Controller:
when click addPeticion:
var peticion = Ext.create('estacionClinica.model.Peticion', {
cip: 'hola',
codigo: 'hola'
//caracterPeticion: [{id: '1', name: ''}]
});
var formularioNuevaPeticion = winPeticion.down('form');
formularioNuevaPeticion.loadRecord(peticion);
winPeticion.show();
When I click on save:
var ventanaNuevaPeticion = button.up('window');
var formularioNuevaPeticion = ventanaNuevaPeticion.down('form');
var registroPeticion = formularioNuevaPeticion.getRecord();
var datosPeticion = formularioNuevaPeticion.getValues();
registroPeticion.set(datosPeticion);
registroPeticion.setCaracterPeticion(registroPeticion);
registroPeticion.setAmbitoPeticion(this.getComboAmbitoPeticion().findRecordByValue(this.getComboAmbitoPeticion().getValue()));
registroPeticion.setCaracterPeticion(this.getComboCaracterPeticion().findRecordByValue(this.getComboCaracterPeticion().getValue()));
this.getPeticionStore().add(registroPeticion);
this.getPeticionStore().sync();
In payload I can see nothing of my association data:
cip: "hola"
codigo: "hola"
fechaPeticion: ""
id: 0
idProceso: ""
nhc: 0
Aucun commentaire:
Enregistrer un commentaire