PDA

View Full Version : Open combobox on click?



elbino
13 Sep 2010, 1:48 AM
Hallo everybody,

I've got a question relating to the ext js comboboxes. Is it possible to get a combobox drop down by clicking it? I do not mean by clicking the arrow. This works, of course. But I want it to drop down when clicking the field.

Thanks & greetings,
Thomas

Condor
13 Sep 2010, 1:48 AM
Configure the combobox with editable:false

elbino
13 Sep 2010, 1:50 AM
Did it. But then I can't type values. Is it possible to get both? Typing an drop down by clicking?

Condor
13 Sep 2010, 2:05 AM
You could call expand() in the focus event handler.

elbino
13 Sep 2010, 2:16 AM
Ohm, does this work like this?


onFocus : function(){
expand();
}

Condor
13 Sep 2010, 2:47 AM
No, don't override methods. Use listeners, e.g.

listeners: {
focus: function(combo) {
combo.expand();
}
}

elbino
13 Sep 2010, 2:57 AM
Thanks. But this brings "this.list is undefined" in Firebug. My code is now:


function getFieldComboBox(items) {

return new Ext.form.ComboBox({
store: items,
triggerAction: 'all',
lazyRender: true,
emptyText:'Bitte wählen...',
editable: true,
typeAhead: true,
typeAheadDelay: 0,
listeners: {
focus: function(combo){
combo.expand();
}
}
});
}

laurentParis
13 Sep 2010, 3:26 AM
try to add lazyInit: false



function getFieldComboBox(items) {

return new Ext.form.ComboBox({
store: items,
triggerAction: 'all',
lazyInit: false,
lazyRender: true,
emptyText:'Bitte wählen...',
editable: true,
typeAhead: true,
typeAheadDelay: 0,
listeners: {
focus: function(combo){
combo.expand();
}
}
});
}

elbino
13 Sep 2010, 3:33 AM
lazyInit: false does the trick. Thank you!!! :-)

elbino
13 Sep 2010, 5:22 AM
Uh, one more thing: Can I reinitialize the combobox when triggering the focus listener? My problem is that the typeAhead filter does not reinitialize for new grid rows.

Condor
13 Sep 2010, 6:16 AM
That shouldn't happen on a new Ext version (that supports clearFilterOnReset:true).

elbino
13 Sep 2010, 6:23 AM
Okay, thanks. :-)