简体   繁体   中英

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'
                            }]
                }]
    });

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);
 },
.
.
.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM