現在受け入れられている解決策はうまく機能しますが、単純な HTML 選択ボックスのようにキーボード入力も処理する ComboBox が必要な場合 (たとえば、「P」を押すたびに、「P」で始まるリスト内の次の項目が選択されます)、以下が役立つ場合があります。
{
xtype: 'combo',
fieldLabel: 'Price',
name: 'price',
hiddenName: 'my_dropdown',
autoSelect: false,
allowBlank: false,
editable: false,
triggerAction: 'all',
typeAhead: true,
width:120,
listWidth: 120,
enableKeyEvents: true,
mode: 'local',
store: [
['val1', 'Appaloosa'],
['val2', 'Arabian'],
['val3', 'Clydesdale'],
['val4', 'Paint'],
['val5', 'Palamino'],
['val6', 'Quarterhorse'],
],
listeners: {
keypress: function(comboBoxObj, keyEventObj) {
// Ext.Store names anonymous fields (like in array above) "field1", "field2", etc.
var valueFieldName = "field1";
var displayFieldName = "field2";
// Which drop-down item is already selected (if any)?
var selectedIndices = this.view.getSelectedIndexes();
var currentSelectedIndex = (selectedIndices.length > 0) ? selectedIndices[0] : null;
// Prepare the search criteria we'll use to query the data store
var typedChar = String.fromCharCode(keyEventObj.getCharCode());
var startIndex = (currentSelectedIndex == null) ? 0 : ++currentSelectedIndex;
var matchIndex = this.store.find(displayFieldName, typedChar, startIndex, false);
if( matchIndex >= 0 ) {
this.select(matchIndex);
} else if (matchIndex == -1 && startIndex > 0) {
// If nothing matched but we didn't start the search at the beginning of the list
// (because the user already had somethign selected), search again from beginning.
matchIndex = this.store.find(displayFieldName, typedChar, 0, false);
if( matchIndex >= 0 ) {
this.select(matchIndex);
}
}
if( matchIndex >= 0 ) {
var record = this.store.getAt(matchIndex);
this.setValue(record.get(valueFieldName));
}
}
}
}