PDA

View Full Version : dynamically added panel doesn't show title and content



Wolfie
29 Dec 2009, 7:33 AM
Hi to all, I am new to forum an ext

please be patient for me ;)

So I have this code to generate tabs on tab panel :



var tabPanel = new Ext.TabPanel({
region: 'center',
autoScroll: true,
margins: '0 4 4 0',
activeTab: 0,
items: [myGrid]
});

var index = 0;

function addTab() {
tabPanel.add({
title: 'New Tab ' + (++index),
html: 'Tab Body ' + (index) + '<br/><br/>',
closable: true
});
}

myGrid.on('rowdblclick', addTab);


viewport = new Ext.Viewport({
layout: 'border',
items: [tabPanel]
});


Higher in the code there is onReady function and grid panel which is generated in first tab

Now the problem is that when I am clicking on row in grid panel myGrid.on('rowdblckick', addTab);

The new tab appears but without title and html,
as u can see in code :



var index = 0;

function addTab() {
tabPanel.add({
title: 'New Tab ' + (++index),
html: 'Tab Body ' + (index) + '<br/><br/>',
closable: true
});
}


it should generate title with New tab + index and html with tab body and index number.

Unfortunately the tab title is : [object Object]

and the htnl is infinitly loading.....

Also in firebug i get the 404 not found error with the base file path plus number of the row in grid panel,

Please help

29 Dec 2009, 8:08 AM
if all you're using in the viewport is the tabpanel, then don't use the border layout. use the fit layout.

the "title" attribute is applied to the tabpanel tab strip, not the panel. You'll have to nest a panel inside to have a panel "title".

That said, it's wasteful. why are you going to do that?

Wolfie
29 Dec 2009, 8:36 AM
Ok, I have solved the problem,

I was really my fault,

My file was quite big and down in the code was sam function addTab :"> and it was overriding this one in the code above, now everything is working corectly