Я полагаю, что если для обоих allowBlank
и forceSelection
установлено значение true, у вас действительно не должно быть выбора (иначе у вас не будет allowBlank
, установленного в значение true).
Вот глобальный мод для всех комбо-боксов, которые ведут себя таким образом.
Ext.onReady(function(){
// Allows no selection on comboboxes that has both allowBlank and
// forceSelection set to true
Ext.override( Ext.form.field.ComboBox, {
onChange: function(newVal, oldVal)
{
var me = this;
if ( me.allowBlank && me.forceSelection && newVal === null )
me.reset();
me.callParent( arguments );
},
});
});
Или, альтернативно, этот мод также закрывает средство выбора и запускает событие select
со значением NULL, когда пользователь очищает поле:
Ext.override( Ext.form.field.ComboBox, {
onKeyUp: function( aEvent ) {
var me = this,
iKey = aEvent.getKey();
isValidKey = !aEvent.isSpecialKey() || iKey == aEvent.BACKSPACE || iKey == aEvent.DELETE,
iValueChanged = me.previousValue != this.getRawValue();
me.previousValue = this.getRawValue();
// Prevents the picker showing up when there's no selection
if ( iValueChanged &&
isValidKey &&
me.allowBlank &&
me.forceSelection &&
me.getRawValue() === '' )
{
// Resets the field
me.reset();
// Set the value to null and fire select
me.setValue( null );
me.fireEvent('select', me, null );
// Collapse the picker
me.collapse();
return;
}
me.callParent( arguments );
},
});