PDA

View Full Version : How can I disable the down arrow key in a combobox?



tm8747a
8 Mar 2013, 9:05 AM
I have a combobox with queryMode: 'remote' and I'd like to disable the down arrow. The reason for this is that the store has tons of records and when pressing down it pulls the entire list, which I don't want happening. I thought something like this would work:



this.addListener('specialkey', function(combo, e, eOpts) {
if (e.getKey() == e.DOWN) {
e.stopEvent();
}
});


Unfortunately, this doesn't work. I also tried it with keydown, keyup, and keypress, none of them work. I do have enableKeyEvents set to true and have verified that my event does fire, it just doesn't produce the result I'd want. Is there any way to modify the default behavior?

slemmon
8 Mar 2013, 9:40 AM
This uses a private method from Picker, so use at your own risk, but the following should work for you:

In the combobox config use


onDownArrow: Ext.emptyFn

tm8747a
8 Mar 2013, 11:25 AM
This uses a private method from Picker, so use at your own risk, but the following should work for you:

In the combobox config use


onDownArrow: Ext.emptyFn


I guess it would be nice if it could be done without overriding private methods, but at least this gets the job done! I'll wait a bit and see if somebody has a way of doing it that doesn't require doing this, but otherwise I'll soon just mark this as the answer. Thanks a lot, on more problem solved!

evant
8 Mar 2013, 12:25 PM
On down, it calls on trigger click, which is governed by the triggerAction. The default is "all", you can change it to "query".

skirtle
8 Mar 2013, 1:05 PM
From your description I'd use something like:


minChars: 1,
triggerAction: 'query',

Even if you've hidden the trigger the triggerAction will apply when the down key is pressed.

For more information:

http://skirtlesden.com/articles/extjs-comboboxes-part-2

slemmon
8 Mar 2013, 1:49 PM
tm8747a,
For what it's worth, my first instinct is to always follow skirtle and evant's instincts.

tm8747a
18 Mar 2013, 6:05 AM
From your description I'd use something like:


minChars: 1,
triggerAction: 'query',

Even if you've hidden the trigger the triggerAction will apply when the down key is pressed.

For more information:

http://skirtlesden.com/articles/extjs-comboboxes-part-2

Thanks, worked like a charm!