PDA

View Full Version : Combobox with typeahead false



zeke
10 Jul 2009, 1:42 PM
I would like to create a combobox where the user can either select a value from the combobox or enter in their own. For some reason I can't prevent the combo from automatically trying to select a value when the user starts typing, even when I set typeAhead:false. I've modified one of the examples to illustrate this:



Ext.onReady(function() {
var states = [
['AL', 'Alabama', 'The Heart of Dixie'],
['AK', 'Alaska', 'The Land of the Midnight Sun'],
['AZ', 'Arizona', 'The Grand Canyon State'],
['AR', 'Arkansas', 'The Natural State'],
['CA', 'California', 'The Golden State'],
['CO', 'Colorado', 'The Mountain State'],
['CT', 'Connecticut', 'The Constitution State'],
['DE', 'Delaware', 'The First State'],
['DC', 'District of Columbia', "The Nation's Capital"],
['FL', 'Florida', 'The Sunshine State'],
['GA', 'Georgia', 'The Peach State'],
['HI', 'Hawaii', 'The Aloha State'],
['ID', 'Idaho', 'Famous Potatoes']
];

// simple array store
var store = new Ext.data.ArrayStore({
fields: ['abbr', 'state', 'nick'],
data : states
});
var combo = new Ext.form.ComboBox({
store: store,
displayField:'state',
typeAhead: false,
mode: 'local',
triggerAction: 'all',
emptyText:'Select a state...',
selectOnFocus:false
});

var window = new Ext.Window({
height:500,
width:800,
items:[combo]
});
window.show();

}); // eo function onReady
So say for example the user wants to enter the value 'Ar'. They select the combobox, type in 'Ar', press tab/enter and the combobox automatically puts in Arizona instead, even though typeAhead is false. Ideally I wouldn't even want the user to get shown the values in the combobox if they don't hit the arrow opening it up.

I've looked through the forums and it seems like other people have had this issue but I can't seem to find a solution. Any help would be greatly appreciated, thanks.

zeke
14 Sep 2009, 10:54 AM
Still can't get this to work. It seems like it should be pretty straightforward. Just want to create a combobox that also allows users to either select from a list of values or type in their own.