PDA

View Full Version : Value & hiddenValue sets in ComboBox, but not displayed



evil_elf
9 Aug 2010, 5:25 AM
Hi all.
I have form with ComboBox and Button_1, and Window, that open by press Button_1 in Form.In this window iam do something and after press Button_2, value and hiddenValue in ComboBox sets by


exhib_cbx.value = obj.exhib_cbx.value;
exhib_cbx.hiddenValue = obj.new_exhib_id;

or with Ext.cmp('cbx_id').setValue, or exhib_cbx.value.setValue(exhib_cbx.value).
All values are set correctly, alert(exhib_cbx.value) or alert(exhib_cbx.hiddenValue) show it, but they not display in ComboBox, when i close the Window, the emptyText still display.
How fix this problem?


query_form = new Ext.FormPanel({
url: ***,
method: 'POST',
plain: true,
monitorValid: true,
defaultType: 'textfield',
renderTo: 'add_query_form',
items: [
exhib_cbx = new Ext.form.ComboBox({
name: 'exhib_id',
id: 'exhib_id',
store: exhibs_store,
forceSelection:true,
typeAhead:true,
allowBlank:false,
minChars: 3,
mode: 'local',
triggerAction: 'all',
width: 300,
displayField: 'exhib_name',
hiddenName: 'exhib_id',
valueField: 'exhib_id',
emptyText:'Change value'
})]})

Condor
9 Aug 2010, 5:36 AM
1. You can't set value and hiddenValue that way! You need to use setValue() and optionally setRawValue().
2. You are using 'exhib_id' as both the hiddenName and the id. These two need to be different!

evil_elf
9 Aug 2010, 5:42 AM
Iam remove "id: 'exhib_id'" from ComboBox, use exhib_cbx.setValue(obj.new_exhib_name); and exhib_cbx.setRawValue(obj.new_exhib_id);, it works! thanks! :)

evil_elf
9 Aug 2010, 5:51 AM
Update:
This code

exhib_cbx.setValue(obj.new_exhib_name); //set value
exhib_cbx.setRawValue(obj.new_exhib_id); //set hiddenValue
set only display value, and its send to server :( Any ideas?

Condor
9 Aug 2010, 6:22 AM
It's setValue(valueField_value) and setRawValue(displayField_value) (it looks like you reversed them).

evil_elf
9 Aug 2010, 6:27 AM
yep, thats it!
after 12 hours of programming head not think %)...