user2865062
user2865062

Reputation: 51

Extjs 4.1: So strange error: Uncaught TypeError: Cannot read property 'items' of undefined

you can change sample: app/simple/app/Viewport.js to this:

you'll get this error in Chrome console:

Uncaught TypeError: Cannot read property 'items' of undefined ext-all.js:18 Ext.cmd.derive.getDockedItems

But if you comment this:

initComponent : function() {
                            this.callParent();
                        },

Everything is ok.

Ext.define('AM.view.Viewport', {
        extend : 'Ext.container.Viewport',

        layout: 'border',
        items : [{
                    border : false,
                    region : 'north',
                    xtype : 'progressbar',
                    text : 'Ready',
                    height : 20
                }, {
                    region : 'west',
                    xtype : 'userlist',
                    width:300
                }, {
                    region : 'center',
                    xtype : 'treepanel',
                    initComponent : function() {
                        this.callParent();
                    },
                    columns : [{
                                xtype : 'treecolumn',
                                sortable : false,
                                width : 200,
                                text : 'lala',
                                dataIndex : 'text'
                            }, {
                                flex : 1,
                                sortable : false,
                                text : 'haha',
                                dataIndex : 'pars'
                            }]
                }]
    });

Upvotes: 5

Views: 9001

Answers (2)

Miisha
Miisha

Reputation: 116

initComponent works only for the newly defined component. In your case for 'AM.view.Viewport'. You can not override initComponent for component inserted as config of component in items. If you want to define initComponent for that treepanel, you have to extend it as well and then put this extension into items of your viewport.

Upvotes: 1

foued611
foued611

Reputation: 359

1- try to call with the Parents arguments like this:

.
.
.
,initComponent : function() {
 this.callParent(arguments);
 },
.
.
.

OR call the the super Class:

.
.

,initComponent : function() {
     this.callSuper(arguments);
 },
.
.
.

Upvotes: 2

Related Questions