Class sap.m.SelectListModule: sap/m/SelectList

extends Control

The sap.m.SelectList displays a list of items that allows the user to select an item.
Since: 1.26.0.
Constructor Summary
new sap.m.SelectList(sId?, mSettings?)Constructor for a new sap.m.SelectList.
Event Summary
itemPress(oControlEvent)This event is fired when an item is pressed.
selectionChange(oControlEvent)This event is fired when the selection has changed.
Events borrowed from class sap.ui.core.Control
Method Summary
sap.m.SelectList.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.m.SelectList with name sClassName and enriches it with the information contained in oClassInfo.
sap.m.SelectList.getMetadata()Returns a metadata object for class sap.m.SelectList.
addAriaLabelledBy(vAriaLabelledBy)Adds some ariaLabelledBy into the association ariaLabelledBy.
addItem(oItem)Adds some item to the aggregation items.
attachItemPress(oData?, fnFunction, oListener?)Attaches event handler fnFunction to the itemPress event of this sap.m.SelectList.
attachSelectionChange(oData?, fnFunction, oListener?)Attaches event handler fnFunction to the selectionChange event of this sap.m.SelectList.
bindItems(oBindingInfo)Binds aggregation items to model data.
clearSelection()Clear the selection.
destroyItems()Destroys all the items in the aggregation named items.
detachItemPress(fnFunction, oListener)Detaches event handler fnFunction from the itemPress event of this sap.m.SelectList.
detachSelectionChange(fnFunction, oListener)Detaches event handler fnFunction from the selectionChange event of this sap.m.SelectList.
fireItemPress(mParameters?)Fires event itemPress to attached listeners.
fireSelectionChange(mParameters?)Fires event selectionChange to attached listeners.
getAriaLabelledBy()Returns array of IDs of the elements which are the current targets of the association ariaLabelledBy.
getDefaultSelectedItem(aItems?)Retrieves the default selected item from the aggregation named items.
getEnabled()Gets current value of property enabled.
getEnabledItems(aItems?)Gets the enabled items from the aggregation named items.
getFirstItem()Gets the first item from the aggregation named items.
getItemAt(iIndex)Gets the item from the aggregation named items at the given 0-based index.
getItemByKey(sKey)Gets the item with the given key from the aggregation named items.
getItems()Gets content of aggregation items.
getKeyboardNavigationMode()Gets current value of property keyboardNavigationMode.
getLastItem()Gets the enabled items from the aggregation named items.
getMaxWidth()Gets current value of property maxWidth.
getSelectedItem()Gets the selected item object from the aggregation named items.
getSelectedItemId()Gets current value of property selectedItemId.
getSelectedKey()Gets current value of property selectedKey.
getShowSecondaryValues()Gets current value of property showSecondaryValues.
getWidth()Gets current value of property width.
indexOfItem(oItem)Checks for the provided sap.ui.core.Item in the aggregation items.
insertItem(oItem, iIndex)Inserts a item into the aggregation items.
removeAllAriaLabelledBy()Removes all the controls in the association named ariaLabelledBy.
removeAllItems()Removes all the items in the aggregation named items.
removeAriaLabelledBy(vAriaLabelledBy)Removes an ariaLabelledBy from the association named ariaLabelledBy.
removeItem(vItem)Removes an item from the aggregation named items.
setEnabled(bEnabled)Sets a new value for property enabled.
setKeyboardNavigationMode(sKeyboardNavigationMode)Sets a new value for property keyboardNavigationMode.
setMaxWidth(sMaxWidth)Sets a new value for property maxWidth.
setSelectedItem(vItem)Sets the selectedItem association.
setSelectedItemId(vItem)Sets property selectedItemId.
setSelectedKey(sKey)Sets property selectedKey.
setSelection(vItem)Updates and synchronizes selectedItem association, selectedItemId and selectedKey properties.
setShowSecondaryValues(bShowSecondaryValues)Sets a new value for property showSecondaryValues.
setWidth(sWidth)Sets a new value for property width.
unbindItems()Unbinds aggregation items from model data.
Constructor Detail
new sap.m.SelectList(sId?, mSettings?)

Constructor for a new sap.m.SelectList.

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

    • items : sap.ui.core.Item[] (default)

  • Associations

  • Events

    • selectionChange : fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject]
    • itemPress : 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.
Event Detail
itemPress(oControlEvent)
This event is fired when an item is pressed.
Parameters:
sap.ui.base.EventoControlEvent
sap.ui.base.EventProvideroControlEvent.getSource
objectoControlEvent.getParameters
sap.ui.core.ItemoControlEvent.getParameters.itemThe pressed item.
Since:
1.32.4
selectionChange(oControlEvent)

This event is fired when the selection has changed.

Note: The selection can be changed by pressing a non-selected item or via keyboard and after the enter or space key is pressed.

Parameters:
sap.ui.base.EventoControlEvent
sap.ui.base.EventProvideroControlEvent.getSource
objectoControlEvent.getParameters
sap.ui.core.ItemoControlEvent.getParameters.selectedItemThe selected item.
Method Detail
sap.m.SelectList.extend(sClassName, oClassInfo?, FNMetaImpl?): function

Creates a new subclass of class sap.m.SelectList 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.SelectList.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.m.SelectList.
Returns:
sap.ui.base.MetadataMetadata object describing this class
addAriaLabelledBy(vAriaLabelledBy): sap.m.SelectList
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.SelectListReference to this in order to allow method chaining
Since:
1.27.0
addItem(oItem): sap.m.SelectList
Adds some item to the aggregation items.
Parameters:
sap.ui.core.ItemoItemthe item to add; if empty, nothing is inserted
Returns:
sap.m.SelectListReference to this in order to allow method chaining
attachItemPress(oData?, fnFunction, oListener?): sap.m.SelectList

Attaches event handler fnFunction to the itemPress event of this sap.m.SelectList.

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

This event is fired when an item is pressed.

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.SelectList itself
Returns:
sap.m.SelectListReference to this in order to allow method chaining
Since:
1.32.4
attachSelectionChange(oData?, fnFunction, oListener?): sap.m.SelectList

Attaches event handler fnFunction to the selectionChange event of this sap.m.SelectList.

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

This event is fired when the selection has changed.

Note: The selection can be changed by pressing a non-selected item or via keyboard and after the enter or space key is pressed.

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.SelectList itself
Returns:
sap.m.SelectListReference to this in order to allow method chaining
bindItems(oBindingInfo): sap.m.SelectList

Binds aggregation items to model data.

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

Parameters:
objectoBindingInfoThe binding information
Returns:
sap.m.SelectListReference to this in order to allow method chaining
clearSelection()
Clear the selection.
destroyItems(): sap.m.SelectList
Destroys all the items in the aggregation named items.
Returns:
sap.m.SelectListthis to allow method chaining.
detachItemPress(fnFunction, oListener): sap.m.SelectList

Detaches event handler fnFunction from the itemPress event of this sap.m.SelectList.

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.SelectListReference to this in order to allow method chaining
Since:
1.32.4
detachSelectionChange(fnFunction, oListener): sap.m.SelectList

Detaches event handler fnFunction from the selectionChange event of this sap.m.SelectList.

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.SelectListReference to this in order to allow method chaining
fireItemPress(mParameters?): sap.m.SelectList
Fires event itemPress to attached listeners.
Parameters:
objectmParameters?Parameters to pass along with the event
sap.ui.core.ItemmParameters.item?The pressed item.
Returns:
sap.m.SelectListReference to this in order to allow method chaining
Since:
1.32.4
fireSelectionChange(mParameters?): sap.m.SelectList
Fires event selectionChange to attached listeners.
Parameters:
objectmParameters?Parameters to pass along with the event
sap.ui.core.ItemmParameters.selectedItem?The selected item.
Returns:
sap.m.SelectListReference to this in order to allow method chaining
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[]
Since:
1.27.0
getDefaultSelectedItem(aItems?): sap.ui.core.Item|null
Retrieves the default selected item from the aggregation named items.
Parameters:
sap.ui.core.Item[]aItems?
Returns:
sap.ui.core.Item|null
getEnabled(): boolean

Gets current value of property enabled.

Indicates whether the user can change the selection.

Default value is true.

Returns:
booleanValue of property enabled
getEnabledItems(aItems?): sap.ui.core.Item[]
Gets the enabled items from the aggregation named items.
Parameters:
sap.ui.core.Item[]aItems?, Default: getItems()items to filter
Returns:
sap.ui.core.Item[]An array containing the enabled items.
getFirstItem(): sap.ui.core.Item|null
Gets the first item from the aggregation named items.
Returns:
sap.ui.core.Item|nullThe first item, or null if there are no items.
getItemAt(iIndex): sap.ui.core.Item|null
Gets the item from the aggregation named items at the given 0-based index.
Parameters:
intiIndexIndex of the item to return.
Returns:
sap.ui.core.Item|nullItem at the given index, or null if none.
getItemByKey(sKey): sap.ui.core.Item|null

Gets the item with the given key from the aggregation named items.

Note: If duplicate keys exists, the first item matching the key is returned.

Parameters:
stringsKeyAn item key that specifies the item to retrieve.
Returns:
sap.ui.core.Item|null
getItems(): sap.ui.core.Item[]

Gets content of aggregation items.

Defines the items contained within this control.

Returns:
sap.ui.core.Item[]
getKeyboardNavigationMode(): sap.m.SelectListKeyboardNavigationMode

Gets current value of property keyboardNavigationMode.

Defines the keyboard navigation mode.

Note: The sap.m.SelectListKeyboardNavigationMode.None enumeration value, is only intended for use in some composite controls that handles keyboard navigation by themselves.

Default value is Delimited.

Returns:
sap.m.SelectListKeyboardNavigationModeValue of property keyboardNavigationMode
Since:
1.38
getLastItem(): sap.ui.core.Item|null
Gets the enabled items from the aggregation named items.
Returns:
sap.ui.core.Item|nullThe last item, or null if there are no items.
getMaxWidth(): sap.ui.core.CSSSize

Gets current value of property maxWidth.

Sets the maximum width of the control.

Default value is 100%.

Returns:
sap.ui.core.CSSSizeValue of property maxWidth
getSelectedItem(): sap.ui.core.Item|null
Gets the selected item object from the aggregation named items.
Returns:
sap.ui.core.Item|nullThe current target of the selectedItem association, or null.
getSelectedItemId(): string

Gets current value of property selectedItemId.

ID of the selected item.

Default value is .

Returns:
stringValue of property selectedItemId
getSelectedKey(): string

Gets current value of property selectedKey.

Key of the selected item.

Note: If duplicate keys exist, the first item matching the key is used.

Default value is .

Returns:
stringValue of property selectedKey
getShowSecondaryValues(): boolean

Gets current value of property showSecondaryValues.

Indicates whether the text values of the additionalText property of a sap.ui.core.ListItem are shown.

Default value is false.

Returns:
booleanValue of property showSecondaryValues
Since:
1.32.3
getWidth(): sap.ui.core.CSSSize

Gets current value of property width.

Sets the width of the control.

Default value is auto.

Returns:
sap.ui.core.CSSSizeValue of property width
indexOfItem(oItem): int
Checks for the provided sap.ui.core.Item in the aggregation items. and returns its index if found or -1 otherwise.
Parameters:
sap.ui.core.ItemoItemThe item whose index is looked for
Returns:
intThe index of the provided control in the aggregation if found, or -1 otherwise
insertItem(oItem, iIndex): sap.m.SelectList
Inserts a item into the aggregation items.
Parameters:
sap.ui.core.ItemoItemthe item to insert; if empty, nothing is inserted
intiIndexthe 0-based index the item should be inserted at; for a negative value of iIndex, the item is inserted at position 0; for a value greater than the current size of the aggregation, the item is inserted at the last position
Returns:
sap.m.SelectListReference to this in order to allow method chaining
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)
Since:
1.27.0
removeAllItems(): sap.ui.core.Item[]
Removes all the items in the aggregation named items. Additionally unregisters them from the hosting UIArea.
Returns:
sap.ui.core.Item[]An array of the removed items (might be empty).
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
Since:
1.27.0
removeItem(vItem): sap.ui.core.Item
Removes an item from the aggregation named items.
Parameters:
int|string|sap.ui.core.ItemvItemThe item to remove or its index or id.
Returns:
sap.ui.core.ItemThe removed item or null.
setEnabled(bEnabled): sap.m.SelectList

Sets a new value for property enabled.

Indicates whether the user can change the selection.

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

Default value is true.

Parameters:
booleanbEnabledNew value for property enabled
Returns:
sap.m.SelectListReference to this in order to allow method chaining
setKeyboardNavigationMode(sKeyboardNavigationMode): sap.m.SelectList

Sets a new value for property keyboardNavigationMode.

Defines the keyboard navigation mode.

Note: The sap.m.SelectListKeyboardNavigationMode.None enumeration value, is only intended for use in some composite controls that handles keyboard navigation by themselves.

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

Default value is Delimited.

Parameters:
sap.m.SelectListKeyboardNavigationModesKeyboardNavigationModeNew value for property keyboardNavigationMode
Returns:
sap.m.SelectListReference to this in order to allow method chaining
Since:
1.38
setMaxWidth(sMaxWidth): sap.m.SelectList

Sets a new value for property maxWidth.

Sets the maximum width of the control.

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

Default value is 100%.

Parameters:
sap.ui.core.CSSSizesMaxWidthNew value for property maxWidth
Returns:
sap.m.SelectListReference to this in order to allow method chaining
setSelectedItem(vItem): sap.m.SelectList
Sets the selectedItem association.
Parameters:
string|sap.ui.core.Item|nullvItemNew value for the selectedItem association. If an ID of a sap.ui.core.Item is given, the item with this ID becomes the selectedItem association. Alternatively, a sap.ui.core.Item instance may be given or null to clear the selection.
Returns:
sap.m.SelectListthis to allow method chaining.
setSelectedItemId(vItem): sap.m.SelectList

Sets property selectedItemId.

Default value is an empty string "" or undefined.

Parameters:
string|undefinedvItemNew value for property selectedItemId.
Returns:
sap.m.SelectListthis to allow method chaining.
setSelectedKey(sKey): sap.m.SelectList

Sets property selectedKey.

Default value is an empty string "" or undefined.

Parameters:
stringsKeyNew value for property selectedKey.
Returns:
sap.m.SelectListthis to allow method chaining.
setSelection(vItem)
Updates and synchronizes selectedItem association, selectedItemId and selectedKey properties.
Parameters:
string|sap.ui.core.Item|nullvItem
setShowSecondaryValues(bShowSecondaryValues): sap.m.SelectList

Sets a new value for property showSecondaryValues.

Indicates whether the text values of the additionalText property of a sap.ui.core.ListItem are shown.

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

Default value is false.

Parameters:
booleanbShowSecondaryValuesNew value for property showSecondaryValues
Returns:
sap.m.SelectListReference to this in order to allow method chaining
Since:
1.32.3
setWidth(sWidth): sap.m.SelectList

Sets a new value for property width.

Sets the width of the control.

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

Default value is auto.

Parameters:
sap.ui.core.CSSSizesWidthNew value for property width
Returns:
sap.m.SelectListReference to this in order to allow method chaining
unbindItems(): sap.m.SelectList
Unbinds aggregation items from model data.
Returns:
sap.m.SelectListReference to this in order to allow method chaining