RadioButton is a control similar to CheckBox, but it allows the user to choose only one of the predefined set of options.
Usually, RadioButton is used in a group with other RadioButtons (with the groupName property or by using sap.ui.commons.RadioButtonGroup), thus providing a limited choice for the user. An event is triggered when the user makes a change of the selection.
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.ui.commons.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 |
Name | Type | Default Value | Description |
---|---|---|---|
editable | boolean | true | Specifies whether the user can select the RadioButton. Visibility: public |
enabled | boolean | true | Displays the disabled controls in another color, depending on the customer settings. Visibility: public |
groupName | string | sapUiRbDefaultGroup | Defines the name of the RadioButtonGroup, in which the current RadioButton belongs to. You can define a new name for the group. If no new name is specified, the default is sapUiRbDefaultGroup. By default, when one of the RadioButtons in a group is selected, all others are unselected. Visibility: public |
key | string | Can be used for subsequent actions. Visibility: public |
|
selected | boolean | false | Specifies the select state of the RadioButton. Visibility: public |
text | string | Defines the text displayed next to the RadioButton. Visibility: public |
|
textDirection | sap.ui.core.TextDirection | Inherit | Defines the text direction - options are left-to-right (LTR) and right-to-left (RTL). Alternatively, the control can inherit the text direction from its parent container. Visibility: public |
valueState | sap.ui.core.ValueState | None | Enumeration sap.ui.core.ValueState provides state values Error, Success, Warning and None. Visibility: public |
width | sap.ui.core.CSSSize | Determines the control width. By default, it depends on the text length. Alternatively, CSS sizes in % or px can be set. 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). |
Method | Description |
---|---|
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 Triggers when the user makes a change on the RadioButton. |
detachSelect |
Detaches event handler The passed function and listener object must match the ones used for event registration. |
sap.ui.commons.RadioButton.extend |
Creates a new subclass of class sap.ui.commons.RadioButton with name
|
fireSelect |
Fires event select to attached listeners. |
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 RadioButton. Default value is |
getEnabled |
Gets current value of property enabled. Displays the disabled controls in another color, depending on the customer settings. Default value is |
getGroupName |
Gets current value of property groupName. Defines the name of the RadioButtonGroup, in which the current RadioButton belongs to. You can define a new name for the group. If no new name is specified, the default is sapUiRbDefaultGroup. By default, when one of the RadioButtons in a group is selected, all others are unselected. Default value is |
getKey |
Gets current value of property key. Can be used for subsequent actions. |
sap.ui.commons.RadioButton.getMetadata |
Returns a metadata object for class sap.ui.commons.RadioButton. |
getSelected |
Gets current value of property selected. Specifies the select state of the RadioButton. Default value is |
getText |
Gets current value of property text. Defines the text displayed next to the RadioButton. |
getTextDirection |
Gets current value of property textDirection. Defines the text direction - options are left-to-right (LTR) and right-to-left (RTL). Alternatively, the control can inherit the text direction from its parent container. Default value is |
getValueState |
Gets current value of property valueState. Enumeration sap.ui.core.ValueState provides state values Error, Success, Warning and None. Default value is |
getWidth |
Gets current value of property width. Determines the control width. By default, it depends on the text length. Alternatively, CSS sizes in % or px can be set. |
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. |
setEditable |
Sets a new value for property editable. Specifies whether the user can select the RadioButton. When called with a value of Default value is |
setEnabled |
Sets a new value for property enabled. Displays the disabled controls in another color, depending on the customer settings. When called with a value of Default value is |
setGroupName |
Sets a new value for property groupName. Defines the name of the RadioButtonGroup, in which the current RadioButton belongs to. You can define a new name for the group. If no new name is specified, the default is sapUiRbDefaultGroup. By default, when one of the RadioButtons in a group is selected, all others are unselected. When called with a value of Default value is |
setKey |
Sets a new value for property key. Can be used for subsequent actions. When called with a value of |
setSelected |
Sets a new value for property selected. Specifies the select state of the RadioButton. When called with a value of Default value is |
setText |
Sets a new value for property text. Defines the text displayed next to the RadioButton. When called with a value of |
setTextDirection |
Sets a new value for property textDirection. Defines the text direction - options are left-to-right (LTR) and right-to-left (RTL). Alternatively, the control can inherit the text direction from its parent container. When called with a value of Default value is |
setValueState |
Sets a new value for property valueState. Enumeration sap.ui.core.ValueState provides state values Error, Success, Warning and None. When called with a value of Default value is |
setWidth |
Sets a new value for property width. Determines the control width. By default, it depends on the text length. Alternatively, CSS sizes in % or px can be set. When called with a value of |
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.ui.commons.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.ui.commons.RadioButton
itself.
Triggers when the user makes a change on the RadioButton.
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.ui.commons.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.ui.commons.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 |
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 RadioButton.
Default value is true
.
Gets current value of property enabled.
Displays the disabled controls in another color, depending on the customer settings.
Default value is true
.
Gets current value of property groupName.
Defines the name of the RadioButtonGroup, in which the current RadioButton belongs to. You can define a new name for the group. If no new name is specified, the default is sapUiRbDefaultGroup. By default, when one of the RadioButtons in a group is selected, all others are unselected.
Default value is 'sapUiRbDefaultGroup'
.
Returns a metadata object for class sap.ui.commons.RadioButton.
Gets current value of property selected.
Specifies the select state of the RadioButton.
Default value is false
.
Gets current value of property textDirection.
Defines the text direction - options are left-to-right (LTR) and right-to-left (RTL). Alternatively, the control can inherit the text direction from its parent container.
Default value is Inherit
.
Gets current value of property valueState.
Enumeration sap.ui.core.ValueState provides state values Error, Success, Warning and None.
Default value is None
.
Gets current value of property width.
Determines the control width. By default, it depends on the text length. Alternatively, CSS sizes in % or px can be set.
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 editable.
Specifies whether the user can select the RadioButton.
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.
Displays the disabled controls in another color, depending on the customer settings.
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 a new value for property groupName.
Defines the name of the RadioButtonGroup, in which the current RadioButton belongs to. You can define a new name for the group. If no new name is specified, the default is sapUiRbDefaultGroup. By default, when one of the RadioButtons in a group is selected, all others are unselected.
When called with a value of null
or undefined
, the default value of the property will be restored.
Default value is 'sapUiRbDefaultGroup'
.
Param | Type | DefaultValue | Description |
---|---|---|---|
sGroupName | string | 'sapUiRbDefaultGroup' |
New value for property |
Sets a new value for property key.
Can be used for subsequent actions.
When called with a value of null
or undefined
, the default value of the property will be restored.
Param | Type | DefaultValue | Description |
---|---|---|---|
sKey | string |
New value for property |
Sets a new value for property selected.
Specifies the select state of the RadioButton.
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 |
---|---|---|---|
bSelected | boolean | false |
New value for property |
Sets a new value for property text.
Defines 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 textDirection.
Defines the text direction - options are left-to-right (LTR) and right-to-left (RTL). 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 valueState.
Enumeration sap.ui.core.ValueState provides state values Error, Success, Warning and None.
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.
Determines the control width. By default, it depends on the text length. Alternatively, CSS sizes in % or px can be set.
When called with a value of null
or undefined
, the default value of the property will be restored.
Param | Type | DefaultValue | Description |
---|---|---|---|
sWidth | sap.ui.core.CSSSize |
New value for property |