PDA

View Full Version : How to prevent user input of non-existent value in editable combobox?



Ex_Soft
17 Jul 2012, 12:32 PM
I have editable combobox with queryMode 'local'. Store is filled a lot of data. I've enabled to edit combobox to quickly select option. But user can input non-existent value. How to prevent the input of non-existent value?

scottmartin
17 Jul 2012, 2:00 PM
Have you tried: forceSelection: true

Scott.

Ex_Soft
17 Jul 2012, 11:32 PM
Have you tried: forceSelection: true
Yes.

fieldComboBox = Ext.create("Ext.form.field.ComboBox", {
store: Ext.create("Ext.data.Store", {
fields: [
{ name: "id", type: "int" },
{ name: "name", type: "string" }
],
data: [
{ id: 1, name: "Record# 1" },
{ id: 2, name: "Record# 2" },
{ id: 3, name: "Record# 3" },
{ id: 4, name: "Record# 4" },
{ id: 5, name: "aaa" },
{ id: 6, name: "aaabbb" },
{ id: 7, name: "aaabbbccc" }
]
}),
valueField: "id",
fieldLabel: "ComboBox",
displayField: "name",
queryMode: "local",
editable: true,
typeAhead: true,
forceSelection: true,
valueNotFoundText: "blah-blah-blah"
})

But user can input aaabbbcccddd or ddd

P.S. 4.0.7/4.1.1

friend
18 Jul 2012, 3:36 AM
Note that forceSelection: true may allow free-form text entry, but on blur, the value will be rejected.

Your only other option is to set editable: false, but this prevents typeahead/autocomplete.

Ex_Soft
18 Jul 2012, 3:55 AM
but on blur, the value will be rejected
I've understood this