PDA

View Full Version : Adding panels to a TabPanel



cripkd
13 Aug 2009, 2:13 AM
I ahve this here tabPanel:


var mainArea = new Ext.TabPanel({
title: 'Main Content',
collapsible: false,
region: 'center',
margins: '5 5 5 0',
//xtype: 'tabpanel',

id: 'card-tabs-panel',
plain: true, //remove the header border
activeItem: 0,
defaults: {bodyStyle: 'padding:15px'}
});

It gets added to a viewport, in a border layout.

Then i do this:


mainArea.add({
title: 'Tab 1-ajax',
id:'tab1',
autoScroll:true,
autoWidth:true,
html: 'asdf'
});
mainArea.add({
title: 'Tab 2-ajax',
id:'tab1',
autoScroll:true,
autoWidth:true,
html: ''
});


What this does is to create ONE tab, the first one, then adds the second one a plain panel inside the second.

This is when the initail tabPanel has no items defined. If i have those defined, then everything I add goes as normal panels inside the first pre-defined tab.
Why?

cripkd
13 Aug 2009, 3:27 AM
Is there some sort of foolproof mechanism for people like me on this forum, that would prevent me from asking stuff before checking every line of code? :)
I have used the same id for the tabs above, thats why they don't work as expected.

Animal
13 Aug 2009, 3:38 AM
Is there some sort of foolproof mechanism for people like me on this forum, that would prevent me from asking stuff before checking every line of code? :)
I have used the same id for the tabs above, thats why they don't work as expected.

There is talk of an "instrumented" version of Ext.

Possibly a set of overrides (created using Function.createInterceptor) which you can use in your page during development (It would add a lot of overhead) which would add checking.

So checking that any configured id is unique would be on the list of thnigs to do.

This idea has gone quiet though.

hendricd
13 Aug 2009, 3:38 AM
When adding anything new to a Container that has already been rendered, YOU must call:

mainArea.doLayout();

after your new items are added. (And resolve your duplicate id's)

cripkd
13 Aug 2009, 12:28 PM
@Animal: I hope you're joking, as I was, cos it was funny :)

Animal
13 Aug 2009, 12:42 PM
No, checking for things like this can be injected. There are place to add checks for common mistakes as a set of overrides.

cripkd
13 Aug 2009, 12:47 PM
Well, I was thinking more like a slap to the back of your head type of mechanism. No overhead there.