PDA

View Full Version : Toolbar, change panel content



alberto01
11 Oct 2010, 4:02 PM
Help,
i don't understand.
I have this code:

Ext.onReady(function(){
Ext.QuickTips.init();


viewport = new Ext.Viewport ({
layout: 'border',
items : [
{
xtype: 'panel',
region: 'north',
html: '<b>ADMIN</b>',
padding: 10,
bodyStyle: 'background-color: #DEDEDE;',
split: true,
bbar: gui.toolbar.getToolbar(this)
},
{
xtype: 'panel',
region: 'center',
split: true,
border: false,
id: 'centerPanel',
title: 'coap',
items: [ gui.main.showAnag() ]
}
]
})
});

and this id the toolbar code:


gui.toolbar = {
getFirstToolbar: function(pannello){
var toReturn = new Ext.Toolbar({
region: 'center',
collapsible: true,
margins: '0,0,0,0',
items: [
{
xtype: 'button',
text: 'Anagrafica fornitori',
handler: function(){
viewport.getItemId('centerPanel') = new panel ////// ???
}
}, .....


I want to create a new panel on the click event...
But I dunno how....

can you help me... plz


thanks

Condor
12 Oct 2010, 3:15 AM
1. There is no 'getItemId' method. You want 'getComponent'.
2. You can't replace the center panel, but you can add another child item, e.g.

var centerPanel = viewport.getComponent('centerPanel');
centerPanel.add(new Panel({title: 'Hello World!'});
centerPanel.doLayout();
3. You need to choose a layout for centerPanel (depending on how you want the added panel to be shown).

alberto01
13 Oct 2010, 9:45 AM
tnx it works!