extjs combo override : why define this.addevents()?
In the existing ext js code in the application, a combo box is overriden like this:
Ext.override(Ext.form.ComboBox, {
nullable:true
,initComponent: Ext.form.ComboBox.prototype.initComponent.createSequence(function(){
this.triggerConfig = {
tag:'span', cls:'x-form-twin-triggers', cn:[
{tag: "img", src: Ext.BLANK_IMAGE_URL, cls:'x-form-trigger '},
{tag: "img", src: Ext.BLANK_IMAGE_URL, cls:'x-form-trigger x-form-clear-trigger'}
]};
this.addEvents(
'clear',
'change'
);
}})
Why do we need to defin开发者_如何学Ce:
this.addEvents(
'clear',
'change'
);
'change' is already defined as an event for combobox in extjs. 'clear' is not defined in extjs.
EDIT: Maybe a reference to the actual example will help: Here it is. http://www.sencha.com/forum/showthread.php?84300-Nullable-ComboBox&p=404222&langid=14
You'll see that there's this method defined there:
clearValue:Ext.form.ComboBox.prototype.clearValue.createSequence(function(){
if(this.trigger_clear){
this.trigger_clear.hide();
}
this.fireEvent('clear', this);
this.fireEvent('change', this);
})
So both events are called with only one argument passed (being the combobox itself). I don't think it was necessary to define change
event here, since it is inherited from Ext.form.Field
. Also the signature of inherited change
event is (field, newValue, oldValue)
while here, only one argument is passed. Because of that, I think another name should be used for this event.
精彩评论