Continuing to build our first custom class, we get into overriding methods. As we have previously mentioned, we can override a method of our parent class by defining a method of the same name in the child class. A key component of the Panel class is the initComponent()
method, which (as the name suggests) initializes the Panel component. Most methods will never need to be overridden, but sometimes we'll need to override a specific method to add to, or change, the default behavior of a component.
initComponent: function(){ CRM.panels.ContactDetails.superclass.initComponent.call(this); if (typeof this.tpl === 'string') { this.tpl = new Ext.XTemplate(this.tpl); } },
Note
Ext JS uses superclass
as the programmatic reference to the object's parent class object, as CRM.panels.ContactDetails
is a subclass of its parent (superclass) Ext.Panel
.
With our component, we needed a way to apply a new XTemplate
to our component, should one be passed into our ContactDetails
class. As a developer...