No need to call show() and no need to call doLayout().
Run this:
Code:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Dynamic Tab Test</title>
<link rel="stylesheet" type="text/css" href="extjs/resources/css/ext-all.css">
<script type="text/javascript" src="extjs/ext-all-debug-w-comments.js"></script>
<script type="text/javascript">
Ext.onReady(function() {
Ext.create('Ext.container.Viewport', {
layout: 'border',
items: [{
xtype: 'panel',
frame: true,
height: 60,
html: '<span style="font-size: 24px;">Banner Text</span>',
layout: 'fit',
title: 'North Region',
region: 'north'
},{
xtype: 'panel',
region: 'west',
collapsible: true,
frame: true,
items: [{
xtype: 'button',
text: 'Add Tab',
handler: function() {
var tp = Ext.ComponentQuery.query('#tabPanel')[0];
var tabs = tp.items.length;
var newTab = tabs+1;
tp.add({
xtype: 'panel',
html: 'New Tab ' + newTab,
title: 'Tab ' + newTab
});
tp.setActiveTab(tabs);
}
}],
title: 'Menu Panel',
width: 150,
},{
xtype: 'tabpanel',
region: 'center',
itemId: 'tabPanel',
items: [{
xtype: 'panel',
html: 'Tab 1',
title: 'Tab 1'
}]
}]
});
});
</script>
</head>
<body>
</body>
</html>