Vi Veri Veniversum Vivus Vici
We need to implement overflowHandler for toolbar layout, which will add second toolbar and wraps components from first toolbar to second when them cannot be displayed because there isn't enough width of toolbar's container.
First, we need to override Ext.panel.Panel:
First, we need to override Ext.panel.Panel:
Ext4.override(Ext4.panel.Panel, { bridgeToolbars : function () { var toolbar; this.callParent(arguments); if (this.tbar2) { if (Ext4.isArray(this.tbar2)) { toolbar = { xtype : 'toolbar', items : this.tbar2 }; } else if (!toolbar.xtype) { toolbar.xtype = 'toolbar'; } toolbar.dock = 'top'; toolbar.isTbar2 = true; this.dockedItems = this.dockedItems.concat(toolbar); this.tbar2 = null; } }, onRender : function () { this.callParent(arguments); var topBars = this.getDockedItems('toolbar[dock="top"]'), i, len; for (i = 0, len = topBars.length; i < len; i++) { if (topBars[i].isTbar2) { this.tbar2 = topBars[i]; break; } } }, /** * Creates, if not exists, and returns toolbar at passed position * @param {Ext.panel.Panel} panel * @param {String} position * @return {Ext.toolbar.Toolbar} */ getDynamicTBar : function (position) { var panel = this, params, tb; position = position || 'top'; if (position === 'tbar2') { tb = panel.tbar2; params = { dock : 'top', isTbar2 : true, layout : { overflowHandler : 'Scroller' } }; } else { tb = panel.getDockedItems('toolbar[dock="' + position + '"]'); params = {dock : position}; if (tb.length > 0) { tb = tb[0]; } } if (!tb) { tb = Ext4.create('Ext4.toolbar.Toolbar', params); panel.addDocked(tb); if (position === 'tbar2') { panel.tbar2 = tb; } } return tb; } });