Class sap.m.ComboBoxModule: sap/m/ComboBox

extends ComboBoxBase

The sap.m.ComboBox control combines a dropdown list with items and a text field with a button, allowing the user to either type a value directly or choose from the list of existing items.


Since: 1.22.
Constructor Summary
new sap.m.ComboBox(sId?, mSettings?)Constructor for a new sap.m.ComboBox.
Event Summary
selectionChange(oControlEvent)This event is fired when the user types something that matches with an item in the list; it is also fired when the user presses on a list item, or when navigating via keyboard.
Events borrowed from class sap.m.ComboBoxBase
Events borrowed from class sap.m.InputBase
Events borrowed from class sap.ui.core.Control
Method Summary
sap.m.ComboBox.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.m.ComboBox with name sClassName and enriches it with the information contained in oClassInfo.
sap.m.ComboBox.getMetadata()Returns a metadata object for class sap.m.ComboBox.
attachSelectionChange(oData?, fnFunction, oListener?)Attaches event handler fnFunction to the selectionChange event of this sap.m.ComboBox.
createPicker(sPickerType)Creates a picker popup container where the selection should take place.
detachSelectionChange(fnFunction, oListener)Detaches event handler fnFunction from the selectionChange event of this sap.m.ComboBox.
fireSelectionChange(mArguments?)Fires event selectionChange to attached listeners.
getDefaultSelectedItem()Gets the default selected item from the aggregation named items.
getItems()Gets aggregation items.
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.
onBeforeOpen()This event handler is called before the picker popup is opened.
removeItem(vItem)Removes an item from the aggregation named items.
selectText(iSelectionStart, iSelectionEnd)Sets the start and end positions of the current text selection.
setSelectedItem(vItem)Sets the selectedItem association.
setSelectedItemId(vItem)Sets the selectedItemId property.
setSelectedKey(sKey)Sets the selectedKey property.
setShowSecondaryValues(bShowSecondaryValues)Sets a new value for property showSecondaryValues.
synchronizeSelection()Synchronizes the selectedItem association and the selectedItemId property.
Constructor Detail
new sap.m.ComboBox(sId?, mSettings?)
Constructor for a new sap.m.ComboBox.

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:

In addition, all settings applicable to the base type sap.m.ComboBoxBase 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
selectionChange(oControlEvent)
This event is fired when the user types something that matches with an item in the list; it is also fired when the user presses on a list item, or when navigating via keyboard.
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.ComboBox.extend(sClassName, oClassInfo?, FNMetaImpl?): function
Creates a new subclass of class sap.m.ComboBox with name sClassName and enriches it with the information contained in oClassInfo.

oClassInfo might contain the same kind of information as described in sap.m.ComboBoxBase.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.ComboBox.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.m.ComboBox.
Returns:
{sap.ui.base.Metadata} Metadata object describing this class
attachSelectionChange(oData?, fnFunction, oListener?): sap.m.ComboBox
Attaches event handler fnFunction to the selectionChange event of this sap.m.ComboBox.

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

This event is fired when the user types something that matches with an item in the list; it is also fired when the user presses on a list item, or when navigating via keyboard.

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.ComboBox itself
Returns:
{sap.m.ComboBox} Reference to this in order to allow method chaining
createPicker(sPickerType): sap.m.Popover|sap.m.Dialog
Creates a picker popup container where the selection should take place.

To be overwritten by subclasses.

Parameters:
{string}sPickerType
Returns:
{sap.m.Popover|sap.m.Dialog} The picker popup to be used.
detachSelectionChange(fnFunction, oListener): sap.m.ComboBox
Detaches event handler fnFunction from the selectionChange event of this sap.m.ComboBox.

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.ComboBox} Reference to this in order to allow method chaining
fireSelectionChange(mArguments?): sap.m.ComboBox
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.ComboBox} Reference to this in order to allow method chaining
getDefaultSelectedItem(): null
Gets the default selected item from the aggregation named items.
Returns:
{null}
getItems(): sap.ui.core.Item[]
Gets aggregation items.

Note: This is the default aggregation.

Returns:
{sap.ui.core.Item[]}
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
onBeforeOpen()
This event handler is called before the picker popup is opened.
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 be removed or its index or ID.
Returns:
{sap.ui.core.Item} The removed item or null.
selectText(iSelectionStart, iSelectionEnd)
Sets the start and end positions of the current text selection.
Parameters:
{int}iSelectionStart The index of the first selected character.
{int}iSelectionEnd The index of the character after the last selected character.
Since:
1.22.1
setSelectedItem(vItem): sap.m.ComboBox
Sets the selectedItem association.

Default value is null.

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.ComboBox}this to allow method chaining.
setSelectedItemId(vItem): sap.m.ComboBox
Sets the selectedItemId property.

Default value is an empty string "" or undefined.

Parameters:
{string|undefined}vItem New value for property selectedItemId. If the provided vItem is an empty string "" or undefined, the selection is cleared. If the ID has no corresponding aggregated item, the selected item is not changed.
Returns:
{sap.m.ComboBox}this to allow method chaining.
setSelectedKey(sKey): sap.m.ComboBox
Sets the selectedKey property.

Default value is an empty string "" or undefined.

Parameters:
{string}sKey New value for property selectedKey. If the provided sKey is an empty string "" or undefined, the selection is cleared. If duplicate keys exist, the first item matching the key is selected.
Returns:
{sap.m.ComboBox}this to allow method chaining.
setShowSecondaryValues(bShowSecondaryValues): sap.m.ComboBox
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.ComboBox} Reference to this in order to allow method chaining
synchronizeSelection()
Synchronizes the selectedItem association and the selectedItemId property.