/** * @class Ext.toolbar.Toolbar * @extends Ext.container.Container *Basic Toolbar class. Although the
*{@link Ext.container.Container#defaultType defaultType}
for Toolbar * is{@link Ext.button.Button button}
, Toolbar elements (child items for the Toolbar container) may * be virtually any type of Component. Toolbar elements can be created explicitly via their constructors, * or implicitly via their xtypes, and can be{@link #add}
ed dynamically.Some items have shortcut strings for creation:
*Shortcut xtype Class Description '->' 'tbfill' {@link Ext.toolbar.Fill} begin using the right-justified button container '-' 'tbseparator' {@link Ext.toolbar.Separator} add a vertical separator bar between toolbar items ' ' 'tbspacer' {@link Ext.toolbar.Spacer} add horiztonal space between elements ** * Example usage of various elements: ** Example adding a ComboBox within a menu of a button: *var tb = new Ext.toolbar.Toolbar({ renderTo: document.body, width: 600, height: 100, items: [ { // xtype: 'button', // default for Toolbars, same as 'tbbutton' text: 'Button' }, { xtype: 'splitbutton', // same as 'tbsplitbutton' text: 'Split Button' }, // begin using the right-justified button container '->', // same as {xtype: 'tbfill'}, // Ext.toolbar.Fill { xtype: 'textfield', name: 'field1', emptyText: 'enter search term' }, // add a vertical separator bar between toolbar items '-', // same as {xtype: 'tbseparator'} to create Ext.toolbar.Separator 'text 1', // same as {xtype: 'tbtext', text: 'text1'} to create Ext.toolbar.TextItem {xtype: 'tbspacer'},// same as ' ' to create Ext.toolbar.Spacer 'text 2', {xtype: 'tbspacer', width: 50}, // add a 50px space 'text 3' ] }); *
* @constructor * Creates a new Toolbar * @param {Object/Array} config A config object or an array of buttons to// ComboBox creation var combo = new Ext.form.ComboBox({ store: new Ext.data.ArrayStore({ autoDestroy: true, fields: ['initials', 'fullname'], data : [ ['FF', 'Fred Flintstone'], ['BR', 'Barney Rubble'] ] }), displayField: 'fullname', typeAhead: true, mode: 'local', forceSelection: true, triggerAction: 'all', emptyText: 'Select a name...', selectOnFocus: true, width: 135, getListParent: function() { return this.el.up('.x-menu'); }, iconCls: 'no-icon' //use iconCls if placing within menu to shift to right side of menu }); // put ComboBox in a Menu var menu = new Ext.menu.Menu({ id: 'mainMenu', items: [ combo // A Field in a Menu ] }); // add a Button with the menu tb.add({ text:'Button w/ Menu', menu: menu // assign menu by instance }); *
{@link #add}
* @xtype toolbar */ Ext.define('Ext.toolbar.Toolbar', { extend: 'Ext.container.Container', requires: [ 'Ext.toolbar.Fill', 'Ext.layout.container.HBox', 'Ext.layout.container.VBox' ], alias: 'widget.toolbar', alternateClassName: 'Ext.Toolbar', isToolbar: true, vertical: false, defaultType: 'button', /** * @cfg {String/Object} layout * This class assigns a default layout (layout:'hbox'
). * Developers may override this configuration option if another layout * is required (the constructor must be passed a configuration object in this * case instead of an array). * See {@link Ext.container.Container#layout} for additional information. */ /** * @cfg {Boolean} enableOverflow * Defaults to false. Configuretrue
to make the toolbar provide a button * which activates a dropdown Menu to show items which overflow the Toolbar's width. */ enableOverflow : false, trackMenus: true, baseCls: Ext.baseCSSPrefix + 'toolbar', ariaRole: 'toolbar', ui: 'default', initComponent: function() { var me = this; me.layout = Ext.applyIf(Ext.isString(me.layout) ? { type: me.layout } : me.layout||{}, { type: me.vertical ? 'vbox' : 'hbox', align: me.vertical ? 'center' : 'middle' }); me.callParent(); /** * @event overflowchange * Fires after the overflow state has changed. * @param {Object} c The Container * @param {Boolean} lastOverflow overflow state */ me.addEvents('overflowchange'); }, /** *Adds element(s) to the toolbar -- this function takes a variable number of * arguments of mixed type and adds them to the toolbar.
*Note: See the notes within {@link Ext.container.Container#add}.
* @param {Mixed} arg1 The following types of arguments are all valid:
*