class sap.m.RadioButton

Control sample: sap.m.RadioButton
Visiblity: public
UX Guidelines: Radio Button
Implements: sap.ui.core.IFormContent
Available since: N/A
Module: sap/m/RadioButton
Application Component: CA-UI5-CTR

RadioButton is a control similar to a checkbox, but it allows you to choose only one of the predefined set of options. Multiple radio buttons have to belong to the same group (have the same value for groupName) in order to be mutually exclusive.

It is recommended to use the wrapper control RadioButtonGroup instead of individual radio buttons. This will provide better screen reader support for the user. Use the RadioButton control on its own only if there is a wrapper control that handles the screen reader support. For example, such wrappers are sap.m.List, sap.m.Table and sap.f.GridList.

Structure

Usage

When to use:

When not to use:

Note: The order in which the RadioButtons will be selected one after another is determined upon instantiation of the control. This order is consistent with the ARIA attributes for position, which the same button will receive when added to specific group.

Example: If three buttons are created (button1, button2, button3) in consecutive order, initially they will have the same positions and TAB order. However if after that button1 and button3 are moved to a new group and then button2 is added to the same group, their TAB order and position in this group will be button1, button3, button2.

This control can be a drag source.

Constructor

Constructor for a new RadioButton.

Accepts an object literal mSettings that defines initial property values, aggregated and associated objects as well as event handlers. See sap.ui.base.ManagedObject#constructor for a general description of the syntax of the settings object.

new sap.m.RadioButton(sId?, mSettings?)
Param Type Default Value Description
sId? string

ID for the new control, generated automatically if no ID is given

mSettings? object

Initial settings for the new control Enables users to select a single option from a set of options.


Properties

Name Type Default Value Description
activeHandling boolean true

This is a flag to switch on activeHandling. When it is switched off, there will not be visual changes on active state. Default value is 'true'

Visibility: public
editable boolean true

Specifies whether the user can select the radio button.

Since: 1.25.

Visibility: public
editableParent boolean true

Specifies if the RadioButton should be editable. This property meant to be used by parent controls (e.g. RadioButtoGroup).

Since: 1.61.

Visibility: hidden
enabled boolean true

Specifies if the radio button is disabled.

Visibility: public
groupName string sapMRbDefaultGroup

Name of the radio button group the current radio button belongs to. You can define a new name for the group. If no new name is specified, this radio button belongs to the sapMRbDefaultGroup per default. Default behavior of a radio button in a group is that when one of the radio buttons in a group is selected, all others are unselected.

Note To ensure screen reader support it is recommended to use the RadioButtonGroup wrapper instead of using the groupName property. Use this property only in cases where a wrapper control will handle the screen reader support. For example such wrappers are sap.m.List, sap.m.Table and sap.f.GridList.

Visibility: public
selected boolean false

Specifies the select state of the radio button

Visibility: public
text string

Specifies the text displayed next to the RadioButton

Visibility: public
textAlign sap.ui.core.TextAlign Begin

Specifies the alignment of the radio button. Available alignment settings are "Begin", "Center", "End", "Left", and "Right".

Since: 1.28.

Visibility: public
textDirection sap.ui.core.TextDirection Inherit

Options for the text direction are RTL and LTR. Alternatively, the control can inherit the text direction from its parent container.

Visibility: public
useEntireWidth boolean false

Indicates if the given width will be applied for the whole RadioButton or only it's label. By Default width is set only for the label.

Since: 1.42.

Visibility: public
valueState sap.ui.core.ValueState None

Marker for the correctness of the current value e.g., Error, Success, etc.

Since: 1.25.

Visibility: public
valueStateText string

Defines the text that appears in the tooltip of the RadioButton. If this is not specified, a default text is shown from the resource bundle.

Visibility: hidden
width sap.ui.core.CSSSize empty string

Width of the RadioButton or it's label depending on the useEntireWidth property. By Default width is set only for the label.

Visibility: public

Associations

Name Cardinality Type Description
ariaDescribedBy 0..n sap.ui.core.Control

Association to controls / IDs which describe this control (see WAI-ARIA attribute aria-describedby).

ariaLabelledBy 0..n sap.ui.core.Control

Association to controls / IDs which label this control (see WAI-ARIA attribute aria-labelledby).


Events Overview

Event Description
select

Event is triggered when the user makes a change on the radio button (selecting or unselecting it).

select

Event is triggered when the user makes a change on the radio button (selecting or unselecting it).

Param Type Description
oControlEvent sap.ui.base.Event
getSource sap.ui.base.EventProvider
getParameters object
selected boolean

Checks whether the RadioButton is active or not.


Methods Overview

Method Description
_updateLabelProperties

Maintains the RadioButton's internal Label's text property.

addAriaDescribedBy

Adds some ariaDescribedBy into the association ariaDescribedBy.

addAriaLabelledBy

Adds some ariaLabelledBy into the association ariaLabelledBy.

attachSelect

Attaches event handler fnFunction to the select event of this sap.m.RadioButton.

When called, the context of the event handler (its this) will be bound to oListener if specified, otherwise it will be bound to this sap.m.RadioButton itself.

Event is triggered when the user makes a change on the radio button (selecting or unselecting it).

detachSelect

Detaches event handler fnFunction from the select event of this sap.m.RadioButton.

The passed function and listener object must match the ones used for event registration.

exit

Destroys all related objects to the RadioButton

sap.m.RadioButton.extend

Creates a new subclass of class sap.m.RadioButton with name sClassName and enriches it with the information contained in oClassInfo.

oClassInfo might contain the same kind of information as described in sap.ui.core.Control.extend.

fireSelect

Fires event select to attached listeners.

getAccessibilityInfo

References:

  • sap.ui.core.Control#getAccessibilityInfo

getActiveHandling

Gets current value of property activeHandling.

This is a flag to switch on activeHandling. When it is switched off, there will not be visual changes on active state. Default value is 'true'

Default value is true.

getAriaDescribedBy

Returns array of IDs of the elements which are the current targets of the association ariaDescribedBy.

getAriaLabelledBy

Returns array of IDs of the elements which are the current targets of the association ariaLabelledBy.

getEditable

Gets current value of property editable.

Specifies whether the user can select the radio button.

Default value is true.

getEnabled

Gets current value of property enabled.

Specifies if the radio button is disabled.

Default value is true.

getGroupName

Gets current value of property groupName.

Name of the radio button group the current radio button belongs to. You can define a new name for the group. If no new name is specified, this radio button belongs to the sapMRbDefaultGroup per default. Default behavior of a radio button in a group is that when one of the radio buttons in a group is selected, all others are unselected.

Note To ensure screen reader support it is recommended to use the RadioButtonGroup wrapper instead of using the groupName property. Use this property only in cases where a wrapper control will handle the screen reader support. For example such wrappers are sap.m.List, sap.m.Table and sap.f.GridList.

Default value is 'sapMRbDefaultGroup'.

sap.m.RadioButton.getMetadata

Returns a metadata object for class sap.m.RadioButton.

getSelected

Gets current value of property selected.

Specifies the select state of the radio button

Default value is false.

getText

Gets current value of property text.

Specifies the text displayed next to the RadioButton

getTextAlign

Gets current value of property textAlign.

Specifies the alignment of the radio button. Available alignment settings are "Begin", "Center", "End", "Left", and "Right".

Default value is Begin.

getTextDirection

Gets current value of property textDirection.

Options for the text direction are RTL and LTR. Alternatively, the control can inherit the text direction from its parent container.

Default value is Inherit.

getUseEntireWidth

Gets current value of property useEntireWidth.

Indicates if the given width will be applied for the whole RadioButton or only it's label. By Default width is set only for the label.

Default value is false.

getValueState

Gets current value of property valueState.

Marker for the correctness of the current value e.g., Error, Success, etc.

Default value is None.

getWidth

Gets current value of property width.

Width of the RadioButton or it's label depending on the useEntireWidth property. By Default width is set only for the label.

Default value is empty string.

onsapselect

Pseudo event for pseudo 'select' event... space, enter, ... without modifiers (Ctrl, Alt or Shift)

removeAllAriaDescribedBy

Removes all the controls in the association named ariaDescribedBy.

removeAllAriaLabelledBy

Removes all the controls in the association named ariaLabelledBy.

removeAriaDescribedBy

Removes an ariaDescribedBy from the association named ariaDescribedBy.

removeAriaLabelledBy

Removes an ariaLabelledBy from the association named ariaLabelledBy.

setActiveHandling

Sets a new value for property activeHandling.

This is a flag to switch on activeHandling. When it is switched off, there will not be visual changes on active state. Default value is 'true'

When called with a value of null or undefined, the default value of the property will be restored.

Default value is true.

setEditable

Sets a new value for property editable.

Specifies whether the user can select the radio button.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is true.

setEnabled

Sets a new value for property enabled.

Specifies if the radio button is disabled.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is true.

setGroupName

Sets RadioButton's groupName. Only one radioButton from the same group can be selected

setSelected

Sets the state of the RadioButton to selected.

setTabIndex

Sets the tab index of the control

setText

Sets a new value for property text.

Specifies the text displayed next to the RadioButton

When called with a value of null or undefined, the default value of the property will be restored.

setTextAlign

Sets a new value for property textAlign.

Specifies the alignment of the radio button. Available alignment settings are "Begin", "Center", "End", "Left", and "Right".

When called with a value of null or undefined, the default value of the property will be restored.

Default value is Begin.

setTextDirection

Sets a new value for property textDirection.

Options for the text direction are RTL and LTR. Alternatively, the control can inherit the text direction from its parent container.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is Inherit.

setUseEntireWidth

Sets a new value for property useEntireWidth.

Indicates if the given width will be applied for the whole RadioButton or only it's label. By Default width is set only for the label.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is false.

setValueState

Sets a new value for property valueState.

Marker for the correctness of the current value e.g., Error, Success, etc.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is None.

setWidth

Sets a new value for property width.

Width of the RadioButton or it's label depending on the useEntireWidth property. By Default width is set only for the label.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is empty string.

_updateLabelProperties

Maintains the RadioButton's internal Label's text property.

Param Type DefaultValue Description
sText string

The text to be set

addAriaDescribedBy

Adds some ariaDescribedBy into the association ariaDescribedBy.

Param Type DefaultValue Description
vAriaDescribedBy sap.ui.core.ID sap.ui.core.Control

The ariaDescribedBy to add; if empty, nothing is inserted

addAriaLabelledBy

Adds some ariaLabelledBy into the association ariaLabelledBy.

Param Type DefaultValue Description
vAriaLabelledBy sap.ui.core.ID sap.ui.core.Control

The ariaLabelledBy to add; if empty, nothing is inserted

attachSelect

Attaches event handler fnFunction to the select event of this sap.m.RadioButton.

When called, the context of the event handler (its this) will be bound to oListener if specified, otherwise it will be bound to this sap.m.RadioButton itself.

Event is triggered when the user makes a change on the radio button (selecting or unselecting it).

Param Type DefaultValue Description
oData object

An application-specific payload object that will be passed to the event handler along with the event object when firing the event

fnFunction function(sap.ui.base.Event) : void

The function to be called when the event occurs

oListener object

Context object to call the event handler with. Defaults to this sap.m.RadioButton itself

detachSelect

Detaches event handler fnFunction from the select event of this sap.m.RadioButton.

The passed function and listener object must match the ones used for event registration.

Param Type DefaultValue Description
fnFunction function(sap.ui.base.Event) : void

The function to be called, when the event occurs

oListener object

Context object on which the given function had to be called

exit

Destroys all related objects to the RadioButton

sap.m.RadioButton.extend

Creates a new subclass of class sap.m.RadioButton with name sClassName and enriches it with the information contained in oClassInfo.

oClassInfo might contain the same kind of information as described in sap.ui.core.Control.extend.

Param Type DefaultValue Description
sClassName string

Name of the class being created

oClassInfo object

Object literal with information about the class

FNMetaImpl function

Constructor function for the metadata object; if not given, it defaults to the metadata implementation used by this class

fireSelect

Fires event select to attached listeners.

Param Type DefaultValue Description
mParameters object

Parameters to pass along with the event

selected boolean

Checks whether the RadioButton is active or not.

getAccessibilityInfo

References:

getActiveHandling

Gets current value of property activeHandling.

This is a flag to switch on activeHandling. When it is switched off, there will not be visual changes on active state. Default value is 'true'

Default value is true.

getAriaDescribedBy

Returns array of IDs of the elements which are the current targets of the association ariaDescribedBy.

getAriaLabelledBy

Returns array of IDs of the elements which are the current targets of the association ariaLabelledBy.

getEditable

Gets current value of property editable.

Specifies whether the user can select the radio button.

Default value is true.

getEnabled

Gets current value of property enabled.

Specifies if the radio button is disabled.

Default value is true.

getGroupName

Gets current value of property groupName.

Name of the radio button group the current radio button belongs to. You can define a new name for the group. If no new name is specified, this radio button belongs to the sapMRbDefaultGroup per default. Default behavior of a radio button in a group is that when one of the radio buttons in a group is selected, all others are unselected.

Note To ensure screen reader support it is recommended to use the RadioButtonGroup wrapper instead of using the groupName property. Use this property only in cases where a wrapper control will handle the screen reader support. For example such wrappers are sap.m.List, sap.m.Table and sap.f.GridList.

Default value is 'sapMRbDefaultGroup'.

sap.m.RadioButton.getMetadata

Returns a metadata object for class sap.m.RadioButton.

getSelected

Gets current value of property selected.

Specifies the select state of the radio button

Default value is false.

getText

Gets current value of property text.

Specifies the text displayed next to the RadioButton

getTextAlign

Gets current value of property textAlign.

Specifies the alignment of the radio button. Available alignment settings are "Begin", "Center", "End", "Left", and "Right".

Default value is Begin.

getTextDirection

Gets current value of property textDirection.

Options for the text direction are RTL and LTR. Alternatively, the control can inherit the text direction from its parent container.

Default value is Inherit.

getUseEntireWidth

Gets current value of property useEntireWidth.

Indicates if the given width will be applied for the whole RadioButton or only it's label. By Default width is set only for the label.

Default value is false.

getValueState

Gets current value of property valueState.

Marker for the correctness of the current value e.g., Error, Success, etc.

Default value is None.

getWidth

Gets current value of property width.

Width of the RadioButton or it's label depending on the useEntireWidth property. By Default width is set only for the label.

Default value is empty string.

onsapselect

Pseudo event for pseudo 'select' event... space, enter, ... without modifiers (Ctrl, Alt or Shift)

Param Type DefaultValue Description
oEvent object

provides information for the event

removeAllAriaDescribedBy

Removes all the controls in the association named ariaDescribedBy.

removeAllAriaLabelledBy

Removes all the controls in the association named ariaLabelledBy.

removeAriaDescribedBy

Removes an ariaDescribedBy from the association named ariaDescribedBy.

Param Type DefaultValue Description
vAriaDescribedBy int sap.ui.core.ID sap.ui.core.Control

The ariaDescribedBy to be removed or its index or ID

removeAriaLabelledBy

Removes an ariaLabelledBy from the association named ariaLabelledBy.

Param Type DefaultValue Description
vAriaLabelledBy int sap.ui.core.ID sap.ui.core.Control

The ariaLabelledBy to be removed or its index or ID

setActiveHandling

Sets a new value for property activeHandling.

This is a flag to switch on activeHandling. When it is switched off, there will not be visual changes on active state. Default value is 'true'

When called with a value of null or undefined, the default value of the property will be restored.

Default value is true.

Param Type DefaultValue Description
bActiveHandling boolean true

New value for property activeHandling

setEditable

Sets a new value for property editable.

Specifies whether the user can select the radio button.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is true.

Param Type DefaultValue Description
bEditable boolean true

New value for property editable

setEnabled

Sets a new value for property enabled.

Specifies if the radio button is disabled.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is true.

Param Type DefaultValue Description
bEnabled boolean true

New value for property enabled

setGroupName

Sets RadioButton's groupName. Only one radioButton from the same group can be selected

Param Type DefaultValue Description
sGroupName string

Name of the group to which the RadioButton will belong.

setSelected

Sets the state of the RadioButton to selected.

Param Type DefaultValue Description
bSelected boolean

defines if the radio button is selected

setTabIndex

Sets the tab index of the control

Param Type DefaultValue Description
iTabIndex int

Greater than or equal to -1

setText

Sets a new value for property text.

Specifies the text displayed next to the RadioButton

When called with a value of null or undefined, the default value of the property will be restored.

Param Type DefaultValue Description
sText string

New value for property text

setTextAlign

Sets a new value for property textAlign.

Specifies the alignment of the radio button. Available alignment settings are "Begin", "Center", "End", "Left", and "Right".

When called with a value of null or undefined, the default value of the property will be restored.

Default value is Begin.

Param Type DefaultValue Description
sTextAlign sap.ui.core.TextAlign Begin

New value for property textAlign

setTextDirection

Sets a new value for property textDirection.

Options for the text direction are RTL and LTR. Alternatively, the control can inherit the text direction from its parent container.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is Inherit.

Param Type DefaultValue Description
sTextDirection sap.ui.core.TextDirection Inherit

New value for property textDirection

setUseEntireWidth

Sets a new value for property useEntireWidth.

Indicates if the given width will be applied for the whole RadioButton or only it's label. By Default width is set only for the label.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is false.

Param Type DefaultValue Description
bUseEntireWidth boolean false

New value for property useEntireWidth

setValueState

Sets a new value for property valueState.

Marker for the correctness of the current value e.g., Error, Success, etc.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is None.

Param Type DefaultValue Description
sValueState sap.ui.core.ValueState None

New value for property valueState

setWidth

Sets a new value for property width.

Width of the RadioButton or it's label depending on the useEntireWidth property. By Default width is set only for the label.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is empty string.

Param Type DefaultValue Description
sWidth sap.ui.core.CSSSize ''

New value for property width