class sap.ui.commons.SegmentedButton

Visiblity: public
UX Guidelines:
Implements: sap.ui.commons.ToolbarItemsap.ui.core.IFormContent
Available since: N/A
Module: sap/ui/commons/SegmentedButton
Application Component: CA-UI5-CTR

The SegmentedButton provides a group of multiple buttons. Only one button can be active. The behaviour is more ore less like a radio button group.


Constructor

Constructor for a new SegmentedButton.

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.SegmentedButton(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


Properties

Name Type Default Value Description
enabled boolean true

enabled

Visibility: public

Aggregations

Default Aggregation:

Name Cardinality Type Description
buttons 0..n sap.ui.commons.Button

Buttons


Associations

Name Cardinality Type Description
selectedButton 0..1 sap.ui.commons.Button

Selected Button


Events Overview

Event Description
select

Event fired when button selected

select

Event fired when button selected

Param Type Description
oControlEvent sap.ui.base.Event
getSource sap.ui.base.EventProvider
getParameters object
selectedButtonId string

Id of selected ToggleButton


Methods Overview

Method Description
_rerenderButtons

Rerendering of the Buttons

addButton

Adds some button to the aggregation buttons.

attachSelect

Attaches event handler fnFunction to the select event of this sap.ui.commons.SegmentedButton.

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

Event fired when button selected

destroyButtons

Destroys all the buttons in the aggregation buttons.

detachSelect

Detaches event handler fnFunction from the select event of this sap.ui.commons.SegmentedButton.

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

sap.ui.commons.SegmentedButton.extend

Creates a new subclass of class sap.ui.commons.SegmentedButton 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.

getButtons

Gets content of aggregation buttons.

Buttons

getEnabled

Gets current value of property enabled.

enabled

Default value is true.

sap.ui.commons.SegmentedButton.getMetadata

Returns a metadata object for class sap.ui.commons.SegmentedButton.

getSelectedButton

ID of the element which is the current target of the association selectedButton, or null.

indexOfButton

Checks for the provided sap.ui.commons.Button in the aggregation buttons. and returns its index if found or -1 otherwise.

insertButton

Inserts a button into the aggregation buttons.

removeAllButtons

Removes all the controls from the aggregation buttons.

Additionally, it unregisters them from the hosting UIArea.

removeButton

Removes a button from the aggregation buttons.

setEnabled

Sets a new value for property enabled.

enabled

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

Default value is true.

setSelectedButton

Sets the associated selectedButton.

_rerenderButtons

Rerendering of the Buttons

addButton

Adds some button to the aggregation buttons.

Param Type DefaultValue Description
oButton sap.ui.commons.Button

The button to add; if empty, nothing is inserted

attachSelect

Attaches event handler fnFunction to the select event of this sap.ui.commons.SegmentedButton.

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

Event fired when button selected

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.ui.commons.SegmentedButton itself

destroyButtons

Destroys all the buttons in the aggregation buttons.

detachSelect

Detaches event handler fnFunction from the select event of this sap.ui.commons.SegmentedButton.

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

sap.ui.commons.SegmentedButton.extend

Creates a new subclass of class sap.ui.commons.SegmentedButton 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

selectedButtonId string

Id of selected ToggleButton

getButtons

Gets content of aggregation buttons.

Buttons

getEnabled

Gets current value of property enabled.

enabled

Default value is true.

sap.ui.commons.SegmentedButton.getMetadata

Returns a metadata object for class sap.ui.commons.SegmentedButton.

getSelectedButton

ID of the element which is the current target of the association selectedButton, or null.

indexOfButton

Checks for the provided sap.ui.commons.Button in the aggregation buttons. and returns its index if found or -1 otherwise.

Param Type DefaultValue Description
oButton sap.ui.commons.Button

The button whose index is looked for

insertButton

Inserts a button into the aggregation buttons.

Param Type DefaultValue Description
oButton sap.ui.commons.Button

The button to insert; if empty, nothing is inserted

iIndex int

The 0-based index the button should be inserted at; for a negative value of iIndex, the button is inserted at position 0; for a value greater than the current size of the aggregation, the button is inserted at the last position

removeAllButtons

Removes all the controls from the aggregation buttons.

Additionally, it unregisters them from the hosting UIArea.

removeButton

Removes a button from the aggregation buttons.

Param Type DefaultValue Description
vButton int string sap.ui.commons.Button

The button to remove or its index or id

setEnabled

Sets a new value for property enabled.

enabled

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

setSelectedButton

Sets the associated selectedButton.

Param Type DefaultValue Description
oSelectedButton sap.ui.core.ID sap.ui.commons.Button

ID of an element which becomes the new target of this selectedButton association; alternatively, an element instance may be given