PDA

View Full Version : ComboBox valueField problem



Nexus3
17 May 2011, 1:59 AM
Hi, ive a problem with the valueField of a combo.

Im working over ExtJs example Dynamic Form interacting whith an embedded Grid. When i select a grids row the values load in the form.
One field of this form is a combo. This combo load from a store by ajax. When i submit the form, the value of the combo is not the value that i need.

Show the code:

//First i create the store

var storeComboFormularioMarca = new Ext.data.JsonStore({
url: 'globals/ajaxComboFormularioMarca.class.php',
method:'POST',
root: 'data',
totalProperty: 'total',
fields: ['referencia','nombre']

});

//Then i create the template

var resultTpl3 = new Ext.XTemplate(
'<tpl for="."><div class="search-item" >',
'<span ><b>Nombre: </b> {nombre}<br /><b>Referencia: </b> {referencia}</span>',

'</div></tpl>'
);

//And then i create the combo

var comboFormularioMarca = new Ext.form.ComboBox({
store: storeComboFormularioMarca,
mode: 'remote',
fieldLabel: 'Marca',
name: 'marca',
displayField: 'nombre',
valueField: 'referencia',
loadingText: 'Searching...',
tpl: resultTpl3,
triggerAction: 'all',
itemSelector: 'div.search-item',
listWidth:450

});

When i submit the form, i'm reciving "nombre" in the POST, and i need to recive "referencia". The valueField property is "referencia", so i dont understand why im reciving "nombre".

If somebody knows why.............

Thanks

friend
17 May 2011, 4:39 AM
Add hiddenName: 'referencia' to your combo's config.

Nexus3
17 May 2011, 5:03 AM
Thank you friend!!!!!!!!!!!!!!
I do it and now works well!!!!!!!!!!!!!!!!!!!!!!!
Thanks thanks thanksssssssssss :)