Sencha Documentation

Basic Toolbar class. Although the defaultType for Toolbar is 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 added dynamically.

Some items have shortcut strings for creation:

Shortcut  xtype          Class                  Description
'->'      'tbfill'       Ext.toolbar.Fill       begin using the right-justified button container
'-'       'tbseparator'  Ext.toolbar.Separator  add a vertical separator bar between toolbar items
' '       'tbspacer'     Ext.toolbar.Spacer     add horiztonal space between elements
Example usage of various elements:
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'
    ]
});
Example adding a ComboBox within a menu of a button:
// 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
    });

Config Options

 
enableOverflow : Boolean
Defaults to false. Configure true to make the toolbar provide a button which activates a dropdown Menu to show items ...
Defaults to false. Configure true to make the toolbar provide a button which activates a dropdown Menu to show items which overflow the Toolbar's width.
 
layout : String/Object
This class assigns a default layout (layout:'hbox'). Developers may override this configuration option if another lay...
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 Ext.container.Container.layout for additional information.

Methods

 
add( Mixed arg1, Mixed arg2, Mixed etc. ) : Void
Adds element(s) to the toolbar -- this function takes a variable number of arguments of mixed type and adds them to t...

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 Ext.container.Container.add.

Parameters

  • arg1 : Mixed
    The following types of arguments are all valid:
  • arg2 : Mixed
  • etc. : Mixed

Returns

  • Void

Events

 
overflowchange( Object c, Boolean lastOverflow )
Fires after the overflow state has changed.
Fires after the overflow state has changed.

Parameters

  • c : Object
    The Container
  • lastOverflow : Boolean
    overflow state

Returns

  • Void