PDA

View Full Version : CardPanel Cannot read property 'dom' of null



matthias-js
25 Nov 2012, 8:04 AM
Hi all,

I'm new to Ext-js and here is my question. I want to switch the items inside the card panel, but all I get is 'Cannot read property 'dom' of null'. I can not figure out what I'm doing wrong.

Kind regards
Matthias



Ext.define('TestApp.view.ContentPanel', {
extend:'Ext.Panel',
alias:'widget.contentpanel',
id:'content-panel',
region:'center',
layout:'card',
activeItem:0,
border:false,
items:[
{ html: '<h1>Card 1</h1>' },
{ html: '<h1>Card 2</h1>' }
]
});




Ext.application({
name:'TestApp',
autoCreateViewport:true,
launch:function () {
Ext.widget('contentpanel').getLayout().setActiveItem(1);
}
});


Ext.define('TestApp.view.Viewport', {
extend: 'Ext.container.Viewport',
layout: 'fit',
initComponent: function() {
this.items = [Ext.widget('contentpanel')];
this.callParent();
}
});

mitchellsimoens
27 Nov 2012, 6:37 AM
Ext.widget will create a new instance, you are creating your viewport which you need to resolve the contentpanel and set the activeItem on it.