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
})
});
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
})
});