PDA

View Full Version : Get in a form both valueField and DisplayField



pilotex
30 Jun 2009, 11:57 PM
Hi everyone,

I've a combobox. In the Form.getValues(), i would like to get both the valuedField and the Displayfield cause i sometimes use the valuedField and sometimes the display field.


Anyone has done something about that so far ???

thanks

Condor
1 Jul 2009, 12:03 AM
You'll need to modify the combobox renderer:

Ext.override(Ext.form.ComboBox, {
onRender : function(ct, position){
Ext.form.ComboBox.superclass.onRender.call(this, ct, position);
if(this.hiddenName){
this.hiddenField = this.el.insertSibling({tag:'input', type:'hidden', name: this.hiddenName,
id: (this.hiddenId||this.hiddenName)}, 'before', true);
//this.el.dom.removeAttribute('name');
}
if(Ext.isGecko){
this.el.dom.setAttribute('autocomplete', 'off');
}
if(!this.lazyInit){
this.initList();
}else{
this.on('focus', this.initList, this, {single: true});
}
}
});

Now, you can get the valueField using the hiddenName and the displayField using the name.

pilotex
1 Jul 2009, 12:08 AM
thanks. Works perfectly