O'Reilly logo

Ext JS 4 Web Application Development Cookbook by Stuart Ashworth, Andrew Duncan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Extending Ext JS components

It is regarded as best practice to create each of your components as extensions of Ext JS' own components and store them in separate files. This approach aids code reuse, helps organize your code and makes maintenance a much easier task. In this recipe, we will discuss how to go about extending an Ext JS component to create a pre-configured class and then configuring it to make our own custom component.

How to do it...

We will define an extension of the Ext.panel.Panel class to create a simple display panel.

  1. Define a new class under the Cookbook namespace, which extends the Ext.panel.Panel class:
    Ext.define('Cookbook.DisplayPanel', {
        extend: 'Ext.panel.Panel'
    });
  2. Override the Ext.panel.Panel's initComponent method and call ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required