ComboBox doesn't post user-entered data - with workaround
items: [
new Ext.form.ComboBox({
fieldLabel: 'Acquisition Type',
value: 'myVal',
id:'myComboList',
hiddenName: 'myCombo',
anchor:'95%',
typeAhead: false,
displayField:'name',
editable:true,
triggerAction: 'all',
lazyInit:false,
emptyText:'Select...',
store: getComboBoxDS()
})
]
Consider the case where the combobox consists of three values:
Apple
Orange
Pineapple
If a user selects any of those values, I'm able to read them via. on the server side when responding to a post: ie.
//Java sample...but issue is language-agnostic
String fruit = req.getParameter("myCombo");
will set fruit appropriately to "Apple", "Orange", or "Pineapple"
However, say instead of select an item from the dropdown, a user opts to enter, "Tomato". On the server-side, fruit won't get set to "Tomato".
Work-around:
I updated Ext-all.js to add an onBlur handler to ComboBox, and things are working for me now. FWIW, my onBlur handler just looks like the following:
onBlur : function(){
this.setValue(this.getValue());
},
this forces the combobox to set the value of it's backing hidden field, and everything posts as expected.
One question:
Rather than update ext-all.js directly, it seems like it would be better to just extend ComboBox and add my handler to the sub-class. Can somebody point me in the right direction to get started with sub-classing Ext components?
Cheers.
You should not be modifying ext-all directly, rather add your overrides after it. Instead of adding on onBlur function, you could also just handle that in a listener for the blur event.
forceSelection
forceSelection : Boolean
True to restrict the selected value to one of the values in the list, false to allow the user to set arbitrary text into the field (defaults to false)
This config option is defined by ComboBox.
#If you have any other info about this subject , Please add it free.# |

