Extending Components
When extending classes that inherit from Ext.Component you can follow a specialized pattern which allows you to omit the constructor's definition.
Ext will:
- supply you with a default constructor
- assume your constructor will always take a single config argument
- copy all of the config options to the this scope
- call all of its superclass's constructors (all the way up the inheritance chain)
CustomWindow = Ext.extend(Ext.Window, {
initComponent : function() {
CustomWindow.superclass.initComponent.call(this);
},
newMethod: function() {},
overridenMethod: function() {}
});
Ext.reg('customwindow', CustomWindow);
Benefits:
- Cleaner and more concise code
- Greater extensibility (allows other developers to patch your pseudo-constructor)
- Allows you to take part in Component Model's lazy-instantiation features