Search code examples
extjs4

Not able to add items to a custom component in extjs


I am extending extjs Container component and making a custom component but when i am adding an item using add function it's giving an error that the add function doesn't exist for my custom component. How can this happen since add function is available for Container and my component is extending that. Here's the code

var row = Ext.define('TableRow',{
        extend: 'Ext.container.Container',
        layout: {
            type: 'table',
            columns: 10
        }
    });

    row.add(); // This line is giving error saying add function is not available for row

Solution

  • Ext.define() is for defining a class. Once the class has been defined, it can be instantiated by calling Ext.create('TableRow');

    Ext.define('TableRow',{
            extend: 'Ext.container.Container',
            layout: {
                type: 'table',
                columns: 10
            }
        });
    
    var row = Ext.create('TableRow');
    
    row.add();