PDA

View Full Version : Combobox issue with form getValues method (jQuery Adapter)



tfrjennings
21 Jul 2010, 2:35 AM
Hey All,

I discovered an issue with how the formPanel.getForm.getValue method handles combo boxes in that it returns the text value of the combobox selection rather than the key. My solution to the problem appears to be a little bit kludgey and I would appreciate some feedback!

NOTE: Error only found with jQuery Adapter


function betterFormGetValues(formPanel)
{
var form_items = formPanel.getForm().items;

//Iterate through all the form items and locate the xtype "combo"
form_items.each(function(field)
{
if(field.isXType("combo"))
{
//Set the "Raw" element value to the value returned by the normal method (key if present)
field.setRawValue(field.getValue());
}
});

var values = formPanel.getForm().getValues(true); //Standard serialisation call

form_items.each(function(field)
{
if(field.isXType("combo"))
{
//Returns the value back to their previous state
field.setValue(field.getRawValue());
}
});

return values;
}

Animal
21 Jul 2010, 3:05 AM
http://www.sencha.com/learn/Ext_FAQ_ComboBox#submit_.22valueField.22_instead_of_.22displayField.22