extjsextjs4overridingextjs4.1

Best practice for overriding classes / properties in ExtJS?


I have an Ext.form.field.Text and I want to override the setValue function.

What is the recommended way to override this class functionality in ExtJS? Ext.override?


Solution

  • For clarification: By real class modification I mean a intended permanent modification/extension of a class, which should always be done by extending a class. But it is not a temporary solution for just a specific problem (bug-fix, etc.).

    You have at least four options how to override members of (Ext) Classes

    If I missed something or something is (no longer) correct, please comment or feel free to edit.

    As commented by @Eric

    None of these methods allow you to override mixins (such as Ext.form.field.Field). Since mixin functions are copied into classes at the time you define the class, you have to apply your overrides to the target classes directly