PDA

View Full Version : Difference between adding via Object and via w.add{}



kamilmajewski
17 Aug 2008, 1:27 AM
I simply dont get it... :/

Code belowe generates TabPanel (in Ext.onReady)


var content = new Ext.TabPanel({
id: 'tab-panel',
title: 'Zawartosc',
region: 'center',
margins:'3 3 3 3',
cmargins:'3 3 3 3',
resizeTabs:true,
minTabWidth: 100,
tabWidth: 150,
enableTabScroll:true,
deferredRender: false,
defaults: {
autoScroll:true,
border:false
},
items: [{
title: 'tytul',
items: [
new Ext.Panel({
title: 'panel1',
html:'htmlkjhjh'
})
]
},
{
title: 'tytul2',
items: [{
html: 'html'
}]
}]
});


This part adds some content to TabPanel


content.add({
id: 'mfcms',
title:'Witamy w MF CMS',
closable: true,
autoScroll:true,
items: [{
title: 'tytul',
items: [
new Ext.Panel({
title: 'panel1',
html:'htmlkjhjh'
})
]
},
{
title: 'tytul2',
items: [{
html: 'html'
}]
}]
}).show();


And finally i got FUNCTION, where which finds 'tab-panel' via getCMP. but overthere adding anything doesnt WORK.


function tab_add(id, title, url) {
var w = Ext.getCmp('tab-panel');
w.add({
title: title,
html: 'html',
items: [{
title: 'tytul',
items: [
new Ext.Panel({
title: 'panel1',
html:'htmlkjhjh'
})
]
},
{
title: 'tytul2',
items: [{
html: 'html'
}]
}]
}).show();
}


Im stuck - i suppose that my way of logic is not quite in line with EXTJS... :/
Help... i lost 2 days already to find out what is going on...

Animal
17 Aug 2008, 1:49 AM
Do you want html or items? You can't have it both ways.