PDA

View Full Version : Override Combobox with clearable option.



xpurpur
15 Oct 2008, 5:51 AM
Hi!
After searching solution for "clearable" combo I compiled solution for clearable option for combobox. Here it is:


Ext.override(Ext.form.ComboBox, {

clearable: false,

initComponent: Ext.form.ComboBox.prototype.initComponent.createInterceptor(function() {

if (!this.clearable) {
// if not clerable, call native initComponent
return true;
}

Ext.apply(this, {
// workaround (TwinTriggerField is not visible in tab/card panels, rendering problem)
// @see: http://extjs.com/forum/showthread.php?t=17242
anchor: '-10',

getTrigger: Ext.form.TwinTriggerField.prototype.getTrigger,
initTrigger: Ext.form.TwinTriggerField.prototype.initTrigger,
trigger1Class: 'x-form-clear-trigger',
hideTrigger1: true,

reset : Ext.form.Field.prototype.reset.createSequence(function(){
this.triggers[0].hide();
}),

onViewClick : Ext.form.ComboBox.prototype.onViewClick.createSequence(function(){
this.triggers[0].show();
}),

onTrigger2Click : function(){
this.onTriggerClick();
},

onTrigger1Click : function(){
this.clearValue();
this.triggers[0].hide();
this.fireEvent('clear', this);
}
});
Ext.form.TwinTriggerField.prototype.initComponent.apply(this, arguments);
return false; // do not call native initComponent
})
});

samadhi
9 Aug 2009, 9:34 AM
Thank you for your extension, it works fine in all browsers except IE8.

The edit bar is 14px lower than the trigger (Debug bar shows TOP: 14px in its styles appears from nowhere), and i can't override it.

I tried some other twincombo extensions but always get the same result..

Can someone hel me pls to fix this problem ?

It look like:

http://dostojno.ru/1.gif

Animal
9 Aug 2009, 1:00 PM
Use a TwinTriggerCombo: http://extjs.com/forum/showthread.php?p=232225#post232225