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.
column
to a number higher than 1.
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
.
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. |
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. |
editableParent | boolean | true | Specifies if the RadioButton should be editable. This property meant to be used by parent controls (e.g. RadioButtoGroup). |
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 |
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". |
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. |
valueState | sap.ui.core.ValueState | None | Marker for the correctness of the current value e.g., Error, Success, etc. |
valueStateText | string | Defines the text that appears in the tooltip of the |
|
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 |
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). |
Event | Description |
---|---|
select |
Event is triggered when the user makes a change on the radio button (selecting or unselecting it). |
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 When called, the context of the event handler (its Event is triggered when the user makes a change on the radio button (selecting or unselecting it). |
detachSelect |
Detaches event handler 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
|
fireSelect |
Fires event select to attached listeners. |
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 |
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 |
getEnabled |
Gets current value of property enabled. Specifies if the radio button is disabled. Default value is |
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 Default value is |
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 |
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 |
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 |
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 |
getValueState |
Gets current value of property valueState. Marker for the correctness of the current value e.g., Error, Success, etc. Default value is |
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 |
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 Default value is |
setEditable |
Sets a new value for property editable. Specifies whether the user can select the radio button. When called with a value of Default value is |
setEnabled |
Sets a new value for property enabled. Specifies if the radio button is disabled. When called with a value of Default value is |
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 |
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 Default value is |
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 Default value is |
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 Default value is |
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 Default value is |
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 Default value is |
Maintains the RadioButton's internal Label's text property.
Param | Type | DefaultValue | Description |
---|---|---|---|
sText | string |
The text to be set |
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 |
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 |
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 |
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 |
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 |
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. |
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
.
Returns array of IDs of the elements which are the current targets of the association ariaDescribedBy.
Returns array of IDs of the elements which are the current targets of the association ariaLabelledBy.
Gets current value of property editable.
Specifies whether the user can select the radio button.
Default value is true
.
Gets current value of property enabled.
Specifies if the radio button is disabled.
Default value is true
.
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'
.
Gets current value of property selected.
Specifies the select state of the radio button
Default value is false
.
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
.
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
.
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
.
Gets current value of property valueState.
Marker for the correctness of the current value e.g., Error, Success, etc.
Default value is None
.
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
.
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 |
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 |
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 |
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 |
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 |
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 |
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. |
Sets the state of the RadioButton to selected.
Param | Type | DefaultValue | Description |
---|---|---|---|
bSelected | boolean |
defines if the radio button is selected |
Sets the tab index of the control
Param | Type | DefaultValue | Description |
---|---|---|---|
iTabIndex | int |
Greater than or equal to -1 |
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 |
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 |
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 |
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 |
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 |
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 |