I need populate a combobox whit a store, all work fine except one thing. ¿Why the store populate only the displayField and not the valueField.
In this line
form.loadRecord(records[1]);
I set that record in the form, is fine but when i try submit the form i hope the value "2" and not the value "Media".
The code and the example on Jsfiddle for better explanation.
var store = Ext.create('Ext.data.Store', {
fields: ['id', 'status'],
data: [
{ id: '1', status: 'Baja' },
{ id: '2', status: 'Media' },
{ id: '3', status: 'Alta' },
{ id: '4', status: 'Urgente' }
]
});
var formPanel = Ext.create('Ext.form.Panel', {
title: 'Edit Country',
url: 'http://aaa.com/',
items: [
{
xtype: 'combobox',
fieldLabel: 'Nombre',
name: 'status',
anchor: '50%',
displayField: 'status',
valueField: 'id',
store: store
}
],
buttons: [
{
text: 'Guardar',
handler: function () {
var form = formPanel.getForm();
var value = form.getValues();
alert(value.status);
}
}
],
renderTo: Ext.getBody()
});
store.load({
scope: this,
callback: function(records, operation, success) {
var form = formPanel.getForm();
form.loadRecord(records[1]);
}
});
Thanks.