Class sap.m.RadioButtonGroupModule: sap/m/RadioButtonGroup

extends Control
implements IFormContent

This control is used as a wrapper for a group of sap.m.RadioButton controls, which can be used as a single UI element. You can select only one of the grouped radio buttons at a time.

Structure

  • The radio buttons are stored in the buttons aggregation.
  • By setting the columns property, you can create layouts like a 'matrix', 'vertical' or 'horizontal'.
  • Note:For proper display on all devices, we recommend creating radio button groups with only one row or only one column.

Usage

When to use:

  • You want to attach a single event handler on a group of buttons, rather than on each individual button.

When not to use:

  • Do not put two radio button groups right next to each other as it is difficult to determine which buttons belong to which group.

Since: 1.25.0.
Constructor Summary
new sap.m.RadioButtonGroup(sId?, mSettings?)Constructor for a new RadioButtonGroup.
Event Summary
select(oControlEvent)Fires when selection is changed by user interaction.
Events borrowed from class sap.ui.core.Control
Method Summary
sap.m.RadioButtonGroup.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.m.RadioButtonGroup with name sClassName and enriches it with the information contained in oClassInfo.
sap.m.RadioButtonGroup.getMetadata()Returns a metadata object for class sap.m.RadioButtonGroup.
addAriaDescribedBy(vAriaDescribedBy)Adds some ariaDescribedBy into the association ariaDescribedBy.
addAriaLabelledBy(vAriaLabelledBy)Adds some ariaLabelledBy into the association ariaLabelledBy.
addButton(oButton)Adds a new radio button to the group.
attachSelect(oData?, fnFunction, oListener?)Attaches event handler fnFunction to the select event of this sap.m.RadioButtonGroup.
bindButtons(oBindingInfo)Binds aggregation buttons to model data.
clone()Creates a new instance of RadioButtonGroup, with the same settings as the RadioButtonGroup on which the method is called.
destroyButtons()Destroys all radio buttons.
detachSelect(fnFunction, oListener)Detaches event handler fnFunction from the select event of this sap.m.RadioButtonGroup.
fireSelect(mParameters?)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.
getButtons()Gets content of aggregation buttons.
getColumns()Gets current value of property columns.
getEditable()Gets current value of property editable.
getEnabled()Gets current value of property enabled.
getSelectedButton()Returns the selected radio button.
getSelectedIndex()Gets current value of property selectedIndex.
getTextDirection()Gets current value of property textDirection.
getValueState()Gets current value of property valueState.
getWidth()Gets current value of property width.
indexOfButton(oButton)Checks for the provided sap.m.RadioButton in the aggregation buttons.
insertButton(oButton, iIndex)Adds a new radio button to the group at a specified index.
removeAllAriaDescribedBy()Removes all the controls in the association named ariaDescribedBy.
removeAllAriaLabelledBy()Removes all the controls in the association named ariaLabelledBy.
removeAllButtons()Removes all radio buttons.
removeAriaDescribedBy(vAriaDescribedBy)Removes an ariaDescribedBy from the association named ariaDescribedBy.
removeAriaLabelledBy(vAriaLabelledBy)Removes an ariaLabelledBy from the association named ariaLabelledBy.
removeButton()Removes a radio button from the group.
setColumns(iColumns)Sets a new value for property columns.
setEditable(bEditable)Sets the editable property of the RadioButtonGroup.
setEnabled(bEnabled)Sets the enabled property of the RadioButtonGroup.
setSelectedButton(oSelectedButton)Sets the selected sap.m.RadioButton using sap.m.RadioButton.
setSelectedIndex(iSelectedIndex)Sets the selected sap.m.RadioButton using index.
setTextDirection(sTextDirection)Sets a new value for property textDirection.
setValueState(sValueState)Sets ValueState of all radio buttons in the group.
setWidth(sWidth)Sets a new value for property width.
unbindButtons()Unbinds aggregation buttons from model data.
Constructor Detail
new sap.m.RadioButtonGroup(sId?, mSettings?)

Constructor for a new RadioButtonGroup.

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

The supported settings are:

  • Properties

  • Aggregations

    • buttons : sap.m.RadioButton[] (default)

  • Associations

  • Events

    • select : fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject]

In addition, all settings applicable to the base type sap.ui.core.Control can be used as well.

Parameters:
stringsId?ID for the new control, generated automatically if no ID is given
objectmSettings?Initial settings for the new control A wrapper control for a group of radio buttons.
Event Detail
select(oControlEvent)
Fires when selection is changed by user interaction.
Parameters:
sap.ui.base.EventoControlEvent
sap.ui.base.EventProvideroControlEvent.getSource
objectoControlEvent.getParameters
intoControlEvent.getParameters.selectedIndexIndex of the selected RadioButton.
Method Detail
sap.m.RadioButtonGroup.extend(sClassName, oClassInfo?, FNMetaImpl?): function

Creates a new subclass of class sap.m.RadioButtonGroup 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.

Parameters:
stringsClassNameName of the class being created
objectoClassInfo?Object literal with information about the class
functionFNMetaImpl?Constructor function for the metadata object; if not given, it defaults to sap.ui.core.ElementMetadata
Returns:
functionCreated class / constructor function
sap.m.RadioButtonGroup.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.m.RadioButtonGroup.
Returns:
sap.ui.base.MetadataMetadata object describing this class
addAriaDescribedBy(vAriaDescribedBy): sap.m.RadioButtonGroup
Adds some ariaDescribedBy into the association ariaDescribedBy.
Parameters:
sap.ui.core.ID|sap.ui.core.ControlvAriaDescribedBythe ariaDescribedBy to add; if empty, nothing is inserted
Returns:
sap.m.RadioButtonGroupReference to this in order to allow method chaining
addAriaLabelledBy(vAriaLabelledBy): sap.m.RadioButtonGroup
Adds some ariaLabelledBy into the association ariaLabelledBy.
Parameters:
sap.ui.core.ID|sap.ui.core.ControlvAriaLabelledBythe ariaLabelledBy to add; if empty, nothing is inserted
Returns:
sap.m.RadioButtonGroupReference to this in order to allow method chaining
addButton(oButton): sap.m.RadioButtonGroup
Adds a new radio button to the group.
Parameters:
sap.m.RadioButtonoButtonThe button which will be added to the group
Returns:
sap.m.RadioButtonGroupPointer to the control instance for chaining
attachSelect(oData?, fnFunction, oListener?): sap.m.RadioButtonGroup

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

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.RadioButtonGroup itself.

Fires when selection is changed by user interaction.

Parameters:
objectoData?An application-specific payload object that will be passed to the event handler along with the event object when firing the event
functionfnFunctionThe function to be called when the event occurs
objectoListener?Context object to call the event handler with. Defaults to this sap.m.RadioButtonGroup itself
Returns:
sap.m.RadioButtonGroupReference to this in order to allow method chaining
bindButtons(oBindingInfo): sap.m.RadioButtonGroup

Binds aggregation buttons to model data.

See ManagedObject.bindAggregation for a detailed description of the possible properties of oBindingInfo.

Parameters:
objectoBindingInfoThe binding information
Returns:
sap.m.RadioButtonGroupReference to this in order to allow method chaining
Creates a new instance of RadioButtonGroup, with the same settings as the RadioButtonGroup on which the method is called. Event handlers are not cloned.
Returns:
sap.m.RadioButtonGroupNew instance of RadioButtonGroup
destroyButtons(): sap.m.RadioButtonGroup
Destroys all radio buttons.
Returns:
sap.m.RadioButtonGroupPointer to the control instance for chaining
detachSelect(fnFunction, oListener): sap.m.RadioButtonGroup

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

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

Parameters:
functionfnFunctionThe function to be called, when the event occurs
objectoListenerContext object on which the given function had to be called
Returns:
sap.m.RadioButtonGroupReference to this in order to allow method chaining
fireSelect(mParameters?): sap.m.RadioButtonGroup
Fires event select to attached listeners.
Parameters:
objectmParameters?Parameters to pass along with the event
intmParameters.selectedIndex?Index of the selected RadioButton.
Returns:
sap.m.RadioButtonGroupReference to this in order to allow method chaining
getAriaDescribedBy(): sap.ui.core.ID[]
Returns array of IDs of the elements which are the current targets of the association ariaDescribedBy.
Returns:
sap.ui.core.ID[]
getAriaLabelledBy(): sap.ui.core.ID[]
Returns array of IDs of the elements which are the current targets of the association ariaLabelledBy.
Returns:
sap.ui.core.ID[]
getButtons(): sap.m.RadioButton[]

Gets content of aggregation buttons.

Returns a list of the RadioButtons in a RadioButtonGroup

Returns:
sap.m.RadioButton[]
getColumns(): int

Gets current value of property columns.

Specifies the maximum number of radio buttons displayed in one line.

Default value is 1.

Returns:
intValue of property columns
getEditable(): boolean

Gets current value of property editable.

Specifies whether the user can change the selected value of the RadioButtonGroup. When the property is set to false, the control obtains visual styles different from its visual styles for the normal and the disabled state. Additionally, the control is no longer interactive, but can receive focus.

Default value is true.

Returns:
booleanValue of property editable
getEnabled(): boolean

Gets current value of property enabled.

Switches the enabled state of the control. All Radio Buttons inside a disabled group are disabled. Default value is “true”.

Default value is true.

Returns:
booleanValue of property enabled
getSelectedButton(): sap.m.RadioButton
Returns the selected radio button.
Returns:
sap.m.RadioButtonThe selected radio button
getSelectedIndex(): int

Gets current value of property selectedIndex.

Determines the index of the selected/checked RadioButton. Default is 0. If no radio button is selected, the selectedIndex property will return -1.

Default value is 0.

Returns:
intValue of property selectedIndex
getTextDirection(): sap.ui.core.TextDirection

Gets current value of property textDirection.

This property specifies the element's text directionality with enumerated options. By default, the control inherits text direction from the DOM.

Default value is Inherit.

Returns:
sap.ui.core.TextDirectionValue of property textDirection
Since:
1.28.0
getValueState(): sap.ui.core.ValueState

Gets current value of property valueState.

Тhe value state to be displayed for the radio button. Possible values are: sap.ui.core.ValueState.Error, sap.ui.core.ValueState.Warning, sap.ui.core.ValueState.Success and sap.ui.core.ValueState.None. Note: Setting this attribute to sap.ui.core.ValueState.Error when the accessibility feature is enabled, sets the value of the invalid propery for the whole RadioButtonGroup to “true”.

Default value is None.

Returns:
sap.ui.core.ValueStateValue of property valueState
getWidth(): sap.ui.core.CSSSize

Gets current value of property width.

Specifies the width of the RadioButtonGroup.

Returns:
sap.ui.core.CSSSizeValue of property width
indexOfButton(oButton): int
Checks for the provided sap.m.RadioButton in the aggregation buttons. and returns its index if found or -1 otherwise.
Parameters:
sap.m.RadioButtonoButtonThe button whose index is looked for
Returns:
intThe index of the provided control in the aggregation if found, or -1 otherwise
insertButton(oButton, iIndex): sap.m.RadioButtonGroup
Adds a new radio button to the group at a specified index.
Parameters:
sap.m.RadioButtonoButtonThe radio button which will be added to the group
intiIndexThe index, at which the radio button will be added
Returns:
sap.m.RadioButtonGroupPointer to the control instance for chaining
removeAllAriaDescribedBy(): sap.ui.core.ID[]
Removes all the controls in the association named ariaDescribedBy.
Returns:
sap.ui.core.ID[]An array of the removed elements (might be empty)
removeAllAriaLabelledBy(): sap.ui.core.ID[]
Removes all the controls in the association named ariaLabelledBy.
Returns:
sap.ui.core.ID[]An array of the removed elements (might be empty)
removeAllButtons(): Array
Removes all radio buttons.
Returns:
ArrayArray of removed buttons or null
removeAriaDescribedBy(vAriaDescribedBy): sap.ui.core.ID
Removes an ariaDescribedBy from the association named ariaDescribedBy.
Parameters:
int|sap.ui.core.ID|sap.ui.core.ControlvAriaDescribedByThe ariaDescribedBy to be removed or its index or ID
Returns:
sap.ui.core.IDThe removed ariaDescribedBy or null
removeAriaLabelledBy(vAriaLabelledBy): sap.ui.core.ID
Removes an ariaLabelledBy from the association named ariaLabelledBy.
Parameters:
int|sap.ui.core.ID|sap.ui.core.ControlvAriaLabelledByThe ariaLabelledBy to be removed or its index or ID
Returns:
sap.ui.core.IDThe removed ariaLabelledBy or null
removeButton(): sap.m.RadioButton
Removes a radio button from the group.
Returns:
sap.m.RadioButtonThe removed radio button
setColumns(iColumns): sap.m.RadioButtonGroup

Sets a new value for property columns.

Specifies the maximum number of radio buttons displayed in one line.

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

Default value is 1.

Parameters:
intiColumnsNew value for property columns
Returns:
sap.m.RadioButtonGroupReference to this in order to allow method chaining
setEditable(bEditable): sap.m.RadioButtonGroup
Sets the editable property of the RadioButtonGroup. Single buttons preserve the value of their editable property. If the group is set to editable=false the buttons are also displayed and function as read only. Non editable radio buttons can still obtain focus.
Parameters:
booleanbEditableDefines whether the radio buttons should be interactive.
Returns:
sap.m.RadioButtonGroupPointer to the control instance for chaining
setEnabled(bEnabled): sap.m.RadioButtonGroup
Sets the enabled property of the RadioButtonGroup. Single buttons preserve internally the value of their enabled property. If the group is set to enabled=false the buttons are also displayed as disabled and getEnabled returns false.
Parameters:
booleanbEnabledDefines whether the radio buttons should be interactive.
Returns:
sap.m.RadioButtonGroupPointer to the control instance for chaining
setSelectedButton(oSelectedButton): sap.m.RadioButtonGroup
Sets the selected sap.m.RadioButton using sap.m.RadioButton.
Parameters:
sap.m.RadioButtonoSelectedButtonThe item to be selected
Returns:
sap.m.RadioButtonGroupPointer to the control instance for chaining
setSelectedIndex(iSelectedIndex): sap.m.RadioButtonGroup
Sets the selected sap.m.RadioButton using index.
Parameters:
intiSelectedIndexThe index of the radio button which has to be selected
Returns:
sap.m.RadioButtonGroupPointer to the control instance for chaining
setTextDirection(sTextDirection): sap.m.RadioButtonGroup

Sets a new value for property textDirection.

This property specifies the element's text directionality with enumerated options. By default, the control inherits text direction from the DOM.

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

Default value is Inherit.

Parameters:
sap.ui.core.TextDirectionsTextDirectionNew value for property textDirection
Returns:
sap.m.RadioButtonGroupReference to this in order to allow method chaining
Since:
1.28.0
setValueState(sValueState): sap.m.RadioButtonGroup
Sets ValueState of all radio buttons in the group.
Parameters:
stringsValueStateThe value state of the radio group - none, success, warning, error.
Returns:
sap.m.RadioButtonGroupPointer to the control instance for chaining
setWidth(sWidth): sap.m.RadioButtonGroup

Sets a new value for property width.

Specifies the width of the RadioButtonGroup.

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

Parameters:
sap.ui.core.CSSSizesWidthNew value for property width
Returns:
sap.m.RadioButtonGroupReference to this in order to allow method chaining
unbindButtons(): sap.m.RadioButtonGroup
Unbinds aggregation buttons from model data.
Returns:
sap.m.RadioButtonGroupReference to this in order to allow method chaining