2 * @class Ext.container.ButtonGroup
3 * @extends Ext.panel.Panel
4 * <p>Provides a container for arranging a group of related Buttons in a tabular manner.</p>
6 * {@img Ext.container.ButtonGroup/Ext.container.ButtonGroup.png Ext.container.ButtonGroup component}
8 Ext.create('Ext.panel.Panel', {
9 title: 'Panel with ButtonGroup',
12 renderTo: document.body,
13 html: 'HTML Panel Content',
33 menu: [{text: 'Menu Item 1'}]
35 xtype:'splitbutton', text: 'Cut', iconCls: 'add16', menu: [{text: 'Cut Menu Item'}]
37 text: 'Copy', iconCls: 'add16'
39 text: 'Format', iconCls: 'add16'
45 * Create a new ButtonGroup.
46 * @param {Object} config The config object
49 Ext.define('Ext.container.ButtonGroup', {
50 extend: 'Ext.panel.Panel',
51 alias: 'widget.buttongroup',
52 alternateClassName: 'Ext.ButtonGroup',
55 * @cfg {Number} columns The <tt>columns</tt> configuration property passed to the
56 * {@link #layout configured layout manager}. See {@link Ext.layout.container.Table#columns}.
60 * @cfg {String} baseCls Defaults to <tt>'x-btn-group'</tt>. See {@link Ext.panel.Panel#baseCls}.
62 baseCls: Ext.baseCSSPrefix + 'btn-group',
65 * @cfg {Object} layout Defaults to <tt>'table'</tt>. See {@link Ext.container.Container#layout}.
71 defaultType: 'button',
74 * @cfg {Boolean} frame Defaults to <tt>true</tt>. See {@link Ext.panel.Panel#frame}.
80 internalDefaults: {removeMode: 'container', hideParent: true},
82 initComponent : function(){
83 // Copy the component's columns config to the layout if specified
87 me.noTitleCls = me.baseCls + '-notitle';
89 me.layout = Ext.apply({}, {columns: cols}, me.layout);
93 me.addCls(me.noTitleCls);
95 me.callParent(arguments);
98 afterLayout: function() {
101 me.callParent(arguments);
103 // Pugly hack for a pugly browser:
104 // If not an explicitly set width, then size the width to match the inner table
105 if (me.layout.table && (Ext.isIEQuirks || Ext.isIE6) && !me.width) {
106 var t = me.getTargetEl();
107 t.setWidth(me.layout.table.offsetWidth + t.getPadding('lr'));
111 afterRender: function() {
114 //we need to add an addition item in here so the ButtonGroup title is centered
116 me.header.insert(0, {
124 me.callParent(arguments);
128 onBeforeAdd: function(component) {
129 if (component.is('button')) {
130 component.ui = component.ui + '-toolbar';
132 this.callParent(arguments);
136 applyDefaults: function(c) {
137 if (!Ext.isString(c)) {
138 c = this.callParent(arguments);
139 var d = this.internalDefaults;
141 Ext.applyIf(c.initialConfig, d);
151 * @cfg {Array} tools @hide
154 * @cfg {Boolean} collapsible @hide
157 * @cfg {Boolean} collapseMode @hide
160 * @cfg {Boolean} animCollapse @hide
163 * @cfg {Boolean} closable @hide