PDA

View Full Version : Override field at framework level



talha06
26 Jun 2012, 11:47 AM
Hello everyone,

I want to apply a plugin to all fields(numberfield, textfield, datefield, etc.) in the library ExtJS 4.1. Is there anyone who knows how can I do this?As I know, all fields are extended from BaseField. So I tried this; but it didn't work at all. I'll be happy if someone can guide me.Thanks in advance.
Ext.form.BaseField.override({
init : function() {
this.plugins = [ 'clearbutton' ];
}
});

scottmartin
26 Jun 2012, 12:23 PM
You should be able to override using one of the following in Ext4



Ext.define('Ext.form.MyBaseField', {
override: 'Ext.form.field.Base',
functionToOverride: function (id) {
}
});




Ext.override(Ext.form.field.Base, {
functionToOverride: function (id) {
}
});


Regards,
Scott.

skirtle
26 Jun 2012, 4:45 PM
You may have more luck trying to override initComponent rather than init, I'm not sure init exists. Be sure to call the overridden method too or you'll get all sorts of problems.

talha06
26 Jun 2012, 10:40 PM
First of all, thanks a lot for your care.

@scottmartin
I'm not going to override a function; I just want to add a global config to all fields with overriding Ext.form.BaseField..

@skirtle
I've already tried to override initComponent function too..