PDA

View Full Version : Add Toolbar to panel programmatically



Eugene Krivopaltsev
22 Oct 2010, 1:31 PM
I am new with Sencha and extJS and have a question on how to add a toolbar using API rather than using configuration options.

Thanks in advance.

--eugene

I followed an example given in API:
var myToolbar = new Ext.Toolbar({
dock: 'top',
title: 'My Toolbar',
items: [{
text: 'My Button'
}]
});

var myPanel = new Ext.Panel({
dockedItems: [myToolbar],
fullscreen: true,
html: 'Test Panel'
});


I tried to achieve the same without using configuration options of Panel


var myToolbar = new Ext.Toolbar({
dock: 'top',
title: 'My Toolbar',
items: [{
text: 'My Button'
}]
});

var myPanel = new Ext.Panel({
// dockedItems: [myToolbar],
fullscreen: true,
html: 'Test Panel'
});


myPanel.addDocked(myToolbar);

I do not observe the toolbar being added, no errors reported.

blessan
23 Oct 2010, 6:35 AM
after adding try

panel.doComponentLayout() or panel.doLayout()

Eugene Krivopaltsev
24 Oct 2010, 12:53 PM
Thank you very much. It helps.

--eugene