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

extends Control
known direct subclasses: TabStripSelectList

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(mArguments?)Fires event itemPress to attached listeners.
fireSelectionChange(mArguments?)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)
  • 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:
{string}sId? ID for the new control, generated automatically if no ID is given.
{object}mSettings? Initial settings for the new control.
Event Detail
itemPress(oControlEvent)
This event is fired when an item is pressed.
Parameters:
{sap.ui.base.Event}oControlEvent
{sap.ui.base.EventProvider}oControlEvent.getSource
{object}oControlEvent.getParameters
{sap.ui.core.Item}oControlEvent.getParameters.item The 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 an non-selected item or via keyboard and after the enter or space key is pressed.

Parameters:
{sap.ui.base.Event}oControlEvent
{sap.ui.base.EventProvider}oControlEvent.getSource
{object}oControlEvent.getParameters
{sap.ui.core.Item}oControlEvent.getParameters.selectedItem The 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:
{string}sClassName Name of the class being created
{object}oClassInfo? Object literal with information about the class
{function}FNMetaImpl? Constructor function for the metadata object; if not given, it defaults to sap.ui.core.ElementMetadata
Returns:
{function} Created class / constructor function
sap.m.SelectList.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.m.SelectList.
Returns:
{sap.ui.base.Metadata} Metadata object describing this class
addAriaLabelledBy(vAriaLabelledBy): sap.m.SelectList
Adds some ariaLabelledBy into the association ariaLabelledBy.
Parameters:
{string|sap.ui.core.Control}vAriaLabelledBy the ariaLabelledBy to add; if empty, nothing is inserted
Since:
1.27.0
Returns:
{sap.m.SelectList} Reference to this in order to allow method chaining
addItem(oItem): sap.m.SelectList
Adds some item to the aggregation items.
Parameters:
{sap.ui.core.Item}oItem the item to add; if empty, nothing is inserted
Returns:
{sap.m.SelectList} Reference 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:
{object}oData? An application-specific payload object that will be passed to the event handler along with the event object when firing the event
{function}fnFunction The function to be called when the event occurs
{object}oListener? Context object to call the event handler with. Defaults to this sap.m.SelectList itself
Since:
1.32.4
Returns:
{sap.m.SelectList} Reference to this in order to allow method chaining
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 an non-selected item or via keyboard and after the enter or space key is pressed.

Parameters:
{object}oData? An application-specific payload object that will be passed to the event handler along with the event object when firing the event
{function}fnFunction The function to be called when the event occurs
{object}oListener? Context object to call the event handler with. Defaults to this sap.m.SelectList itself
Returns:
{sap.m.SelectList} Reference 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:
{object}oBindingInfo The binding information
Returns:
{sap.m.SelectList} Reference 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.SelectList}this 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:
{function}fnFunction The function to be called, when the event occurs
{object}oListener Context object on which the given function had to be called
Since:
1.32.4
Returns:
{sap.m.SelectList} Reference to this in order to allow method chaining
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:
{function}fnFunction The function to be called, when the event occurs
{object}oListener Context object on which the given function had to be called
Returns:
{sap.m.SelectList} Reference to this in order to allow method chaining
fireItemPress(mArguments?): sap.m.SelectList
Fires event itemPress to attached listeners.

Expects the following event parameters:

  • item of type sap.ui.core.ItemThe pressed item.
Parameters:
{Map}mArguments? The arguments to pass along with the event
Since:
1.32.4
Returns:
{sap.m.SelectList} Reference to this in order to allow method chaining
fireSelectionChange(mArguments?): sap.m.SelectList
Fires event selectionChange to attached listeners.

Expects the following event parameters:

  • selectedItem of type sap.ui.core.ItemThe selected item.
Parameters:
{Map}mArguments? The arguments to pass along with the event
Returns:
{sap.m.SelectList} Reference to this in order to allow method chaining
getAriaLabelledBy(): sap.ui.core.Control[]
Returns array of IDs of the elements which are the current targets of the association ariaLabelledBy.
Since:
1.27.0
Returns:
{sap.ui.core.Control[]}
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:
{boolean} Value 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|null} The 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:
{int}iIndex Index of the item to return.
Returns:
{sap.ui.core.Item|null} Item 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:
{string}sKey An 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.

Since:
1.38
Returns:
{sap.m.SelectListKeyboardNavigationMode} Value of property keyboardNavigationMode
getLastItem(): sap.ui.core.Item|null
Gets the enabled items from the aggregation named items.
Returns:
{sap.ui.core.Item|null} The 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.CSSSize} Value of property maxWidth
getSelectedItem(): sap.ui.core.Item|null
Gets the selected item object from the aggregation named items.
Returns:
{sap.ui.core.Item|null} The 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:
{string} Value 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:
{string} Value 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.

Since:
1.32.3
Returns:
{boolean} Value of property showSecondaryValues
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.CSSSize} Value 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.Item}oItem The item whose index is looked for
Returns:
{int} The 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.Item}oItem the item to insert; if empty, nothing is inserted
{int}iIndex the 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.SelectList} Reference to this in order to allow method chaining
removeAllAriaLabelledBy(): sap.ui.core.Control[]
Removes all the controls in the association named ariaLabelledBy.
Since:
1.27.0
Returns:
{sap.ui.core.Control[]} An array of the removed elements (might be empty)
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.Control
Removes an ariaLabelledBy from the association named ariaLabelledBy.
Parameters:
{int|string|sap.ui.core.Control}vAriaLabelledBy The ariaLabelledByto be removed or its index or ID
Since:
1.27.0
Returns:
{sap.ui.core.Control} the removed ariaLabelledBy or null
removeItem(vItem): sap.ui.core.Item
Removes an item from the aggregation named items.
Parameters:
{int|string|sap.ui.core.Item}vItem The item to remove or its index or id.
Returns:
{sap.ui.core.Item} The 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:
{boolean}bEnabled New value for property enabled
Returns:
{sap.m.SelectList} Reference 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.SelectListKeyboardNavigationMode}sKeyboardNavigationMode New value for property keyboardNavigationMode
Since:
1.38
Returns:
{sap.m.SelectList} Reference to this in order to allow method chaining
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.CSSSize}sMaxWidth New value for property maxWidth
Returns:
{sap.m.SelectList} Reference to this in order to allow method chaining
setSelectedItem(vItem): sap.m.SelectList
Sets the selectedItem association.
Parameters:
{string|sap.ui.core.Item|null}vItem New 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.SelectList}this to allow method chaining.
setSelectedItemId(vItem): sap.m.SelectList
Sets property selectedItemId.

Default value is an empty string "" or undefined.

Parameters:
{string|undefined}vItem New value for property selectedItemId.
Returns:
{sap.m.SelectList}this to allow method chaining.
setSelectedKey(sKey): sap.m.SelectList
Sets property selectedKey.

Default value is an empty string "" or undefined.

Parameters:
{string}sKey New value for property selectedKey.
Returns:
{sap.m.SelectList}this to allow method chaining.
setSelection(vItem)
Updates and synchronizes selectedItem association, selectedItemId and selectedKey properties.
Parameters:
{string|sap.ui.core.Item|null}vItem
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:
{boolean}bShowSecondaryValues New value for property showSecondaryValues
Since:
1.32.3
Returns:
{sap.m.SelectList} Reference to this in order to allow method chaining
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.CSSSize}sWidth New value for property width
Returns:
{sap.m.SelectList} Reference to this in order to allow method chaining
unbindItems(): sap.m.SelectList
Unbinds aggregation items from model data.
Returns:
{sap.m.SelectList} Reference to this in order to allow method chaining