PDA

View Full Version : jump to a record in a combobox using the keyboard



ahsec
24 Feb 2013, 8:47 AM
Hello

I'm using a combobox. I want to know how I can jump to a certain record using the keyboard. i.e:

when opening the dropdown list, when I type "c" I'd like to jump to the records that start with "c".

I already know that the feature exists when the combobox is editable. However, I need to have mine non-editable, and still be able to "jump to" a certain letter.

Does anybody know how?

Thanks

skirtle
24 Feb 2013, 9:41 AM
Like this?


Ext.create('Ext.form.field.ComboBox', {
editable: false,
enableKeyEvents: true,
renderTo: Ext.getBody(),
store: ['Volvo', 'Saab', 'Fiat', 'Audi'],

listeners: {
keyup: function(combo, event) {
var key = String.fromCharCode(event.getKey()),
boundList = combo.getPicker(),
store = boundList.getStore(),
record = store.findRecord(combo.displayField, key);

if (record) {
boundList.highlightItem(boundList.getNode(record));
}
}
}
});

ahsec
24 Feb 2013, 10:32 AM
Thanks for your reply:-)

ahsec
25 Feb 2013, 5:12 AM
Works like charm!!!


B.t.w

I've been trying to use your extension to add a combo box in a cell inside a grid...but I couldn't

Where can I contact you in private?

Thanks

skirtle
25 Feb 2013, 6:45 AM
You could send me a PM on the forums.

Please make sure you've read the forum thread and the page on my website about the extension before you send me any questions directly.