PDA

View Full Version : How to dynamically create tabs?



jeroenvduffelen
10 Aug 2010, 8:39 AM
I know from the examples how to create a pre-populated tabspanel.

But there is no way yet to create them on the fly, after the tabspanel has rendered right?

Any suggestions on how to build it?

evant
10 Aug 2010, 3:46 PM
Of course there is!



Ext.setup({
onReady: function(){
var tabs = new Ext.TabPanel({
fullscreen: true,
items: [{
title: 'A'
}]
});
tabs.add({
title: 'B'
});
tabs.doLayout();
}
});

jeroenvduffelen
10 Aug 2010, 11:17 PM
the "doLayout()" does the trick :)

Can you explain what the difference is with doComponentLayout()?

evant
10 Aug 2010, 11:27 PM
From the docs:



This method needs to be called whenever you change something on this component that requires the components layout to be recalculated. An example is adding, showing or hiding a docked item to a Panel, or changing the label of a form field. After a component layout, the container layout will automatically be run. So you could be on the safe side and always call doComponentLayout instead of doLayout.