One simple solution that can be useful throughout the application is to override the onRender event. Using Ext.util.TextMetrics to calculate text width:
(Here is an example on a radio group)
Ext.define('NG.override.form.field.Radio', { override: 'Ext.form.field.Radio', autoBoxLabelWidth: false, onRender: function () { var me = this, boxlabelWidth; me.callParent(arguments); me.renderActiveError(); if (me.autoBoxLabelWidth) { me.tm = new Ext.util.TextMetrics(me.getEl()); boxlabelWidth = me.tm.getWidth(me.boxLabel) + Ext.Number.from(me.autoBoxLabelWidth, 0); me.setWidth(boxlabelWidth); } } });
Then set the 'autoBoxLabelWidth' property to 'true' or the number of px to add:
xtype: 'radiogroup', fieldLabel: 'Two Columns', columns: 2, vertical: true, items: [{ boxLabel: 'Item 1', name: 'rb', autoBoxLabelWidth: true, inputValue: '1' }, { boxLabel: 'Item 2', name: 'rb', autoBoxLabelWidth: 15, inputValue: '2', checked: true }]
source share