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. 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
. 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
. getSelectedItem()Gets the selected item object from the aggregation named items
. 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. addItem,
attachLoadItems,
bindItems,
clearSelection,
close,
destroyItems,
detachLoadItems,
fireLoadItems,
getEnabledItems,
getFirstItem,
getItemAt,
getItemByKey,
getLastItem,
getList,
getPicker,
getPickerType,
indexOfItem,
insertItem,
isOpen,
open,
removeAllItems,
setPickerType,
unbindItems addAriaLabelledBy,
applyFocusInfo,
attachChange,
bindToInputEvent,
bindValue,
closeValueStateMessage,
detachChange,
fireChange,
fireChangeEvent,
getAriaLabelledBy,
getEditable,
getEnabled,
getFocusInfo,
getName,
getPlaceholder,
getRequired,
getSelectedText,
getShowValueStateMessage,
getTextAlign,
getTextDirection,
getValueState,
getValueStateText,
getWidth,
onChange,
onValueRevertedByEscape,
openValueStateMessage,
removeAllAriaLabelledBy,
removeAriaLabelledBy,
setEditable,
setEnabled,
setName,
setPlaceholder,
setRequired,
setShowValueStateMessage,
setTextAlign,
setTextDirection,
setValue,
setValueState,
setValueStateText,
setWidth,
unbindValue,
updateDomValue addStyleClass,
allowTextSelection,
attachBrowserEvent,
attachValidateFieldGroup,
checkFieldGroupIds,
clone,
detachBrowserEvent,
detachValidateFieldGroup,
fireValidateFieldGroup,
getBusy,
getBusyIndicatorDelay,
getControlsByFieldGroupId,
getFieldGroupIds,
getIdForLabel,
getRenderer,
getVisible,
hasStyleClass,
invalidate,
isBusy,
placeAt,
removeStyleClass,
rerender,
setBusy,
setBusyIndicatorDelay,
setFieldGroupIds,
setVisible,
toggleStyleClass,
triggerValidateFieldGroup $,
addCustomData,
addDependent,
addEventDelegate,
bindElement,
data,
destroy,
destroyCustomData,
destroyDependents,
destroyLayoutData,
destroyTooltip,
enhanceAccessibilityState,
findElements,
fireEvent,
focus,
getCustomData,
getDependents,
getDomRef,
getElementBinding,
getFocusDomRef,
getInterface,
getLayoutData,
getMetadata,
getTooltip,
getTooltip_AsString,
getTooltip_Text,
indexOfCustomData,
indexOfDependent,
insertCustomData,
insertDependent,
prop,
removeAllCustomData,
removeAllDependents,
removeCustomData,
removeDependent,
removeEventDelegate,
setLayoutData,
setTooltip,
toString,
unbindElement addAggregation,
addAssociation,
applySettings,
attachFormatError,
attachModelContextChange,
attachParseError,
attachValidationError,
attachValidationSuccess,
bindAggregation,
bindContext,
bindObject,
bindProperty,
destroyAggregation,
detachFormatError,
detachModelContextChange,
detachParseError,
detachValidationError,
detachValidationSuccess,
findAggregatedObjects,
fireFormatError,
fireModelContextChange,
fireParseError,
fireValidationError,
fireValidationSuccess,
getAggregation,
getAssociation,
getBinding,
getBindingContext,
getBindingInfo,
getBindingPath,
getEventingParent,
getId,
getModel,
getObjectBinding,
getOriginInfo,
getParent,
getProperty,
hasModel,
indexOfAggregation,
insertAggregation,
isBound,
isInvalidateSuppressed,
isTreeBinding,
removeAggregation,
removeAllAggregation,
removeAllAssociation,
removeAssociation,
setAggregation,
setAssociation,
setBindingContext,
setModel,
unbindAggregation,
unbindContext,
unbindObject,
unbindProperty,
validateAggregation,
validateProperty 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:
- Properties
- Events
- selectionChange : fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject]
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:
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 |
Returns a metadata object for class sap.m.ComboBox.
Returns:
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:
Creates a picker popup container where the selection should take place.
To be overwritten by subclasses.
Parameters:
Returns:
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:
Fires event
selectionChange
to attached listeners.
Expects the following event parameters:
selectedItem
of type sap.ui.core.Item
The selected item.
Parameters:
{Map} | mArguments? | The arguments to pass along with the event |
Returns:
getDefaultSelectedItem(): null
Gets the default selected item from the aggregation named items
.
Returns:
Gets aggregation
items
.
Note: This is the default aggregation.
Returns:
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.
Removes an item from the aggregation named items
.
Parameters:
Returns:
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
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:
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:
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:
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:
synchronizeSelection()
Synchronizes the selectedItem
association and the selectedItemId
property.