The control provides a field that allows end users to either enter some text, or to choose an entry out of a list of pre-defined items. The choosable items can be provided in the form of a complete ListBox
, single ListItems
.
Constructor for a new 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#constructor for a general description of the syntax of the settings object.
new sap.ui.commons.ComboBox(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 |
Name | Type | Default Value | Description |
---|---|---|---|
displaySecondaryValues | boolean | false | Indicates whether the |
maxPopupItems | int | 10 | Defines the number of items that shall be displayed at once. If the overall number of items is higher than this setting, a scrollbar is provided. Visibility: public |
selectedItemId | string | Id of the selected item. If the value has no corresponding item, the If the |
|
selectedKey | string | Key of the selected item. If the value has no corresponding item the key is empty. If duplicate keys exists the first item matching the key is used. If the key is set to a not existing value it will not be changed. Visibility: public |
Name | Type | Default Value | Description |
---|---|---|---|
accessibleRole | sap.ui.core.AccessibleRole | Textbox | Accessibility role for the text field. Visibility: public |
design | sap.ui.core.Design | Standard | Font type. valid values are Standard and Monospace. Visibility: public |
editable | boolean | true | Switches edit state of the control. Read-only fields have different colors, depending on theme setting. Visibility: public |
enabled | boolean | true | Switches enabled state of the control. Disabled fields have different colors, and can not be focused. Visibility: public |
helpId | string | empty string | Unique identifier used for help service. Visibility: public |
imeMode | sap.ui.core.ImeMode | Auto | State of the Input Method Editor (IME). Visibility: public |
maxLength | int | 0 | Maximum number of characters. Value '0' means the feature is switched off. Visibility: public |
name | string | The |
|
placeholder | string | Placeholder for the text field. |
|
required | boolean | false | Depending on theme the |
textAlign | sap.ui.core.TextAlign | Begin | Sets the horizontal alignment of the text. Visibility: public |
textDirection | sap.ui.core.TextDirection | Inherit | Direction of the text. Possible values: "rtl", "ltr". Visibility: public |
value | string | empty string | Text inside the |
valueState | sap.ui.core.ValueState | None | Visualizes warnings or errors related to the text field. Possible values: Warning, Error, Success. Visibility: public |
width | sap.ui.core.CSSSize | Width of text field. When it is set (CSS-size such as % or px), this is the exact size. When left blank, the text field length defines the width. Visibility: public |
Default Aggregation: items
Name | Cardinality | Type | Description |
---|---|---|---|
items (default) | 0..n | sap.ui.core.ListItem |
|
myListBox | 0..1 | sap.ui.commons.ListBox |
The hidden |
Name | Cardinality | Type | Description |
---|---|---|---|
listBox | 0..1 | sap.ui.commons.ListBox |
Using this method, you provide a Note: The ListBox must not be rendered somewhere in the UI. But if you want to bind the |
Event | Description |
---|---|
change |
Event is fired when the text in the field has changed AND the focus leaves the ComboBox or the Enter key is pressed. |
Event is fired when the text in the field has changed AND the focus leaves the ComboBox or the Enter key is pressed.
Param | Type | Description |
---|---|---|
oControlEvent | sap.ui.base.Event | |
getSource | sap.ui.base.EventProvider | |
getParameters | object | |
newValue | string |
The new / changed value of the ComboBox. |
selectedItem | sap.ui.core.ListItem |
The new / changed item of the ComboBox. |
Method | Description |
---|---|
_checkChange |
Compares the previous value with the current value and fires the "Change" event if the ComboBox is editable and the value has changed or whether the value has been changed e.g. via up/down or auto-complete feature |
addItem |
Adds some item to the aggregation items. |
bindItems |
Binds aggregation items to model data. See ManagedObject.bindAggregation for a detailed description of the possible properties of |
destroyItems |
Destroys all the items in the aggregation items. |
sap.ui.commons.ComboBox.extend |
Creates a new subclass of class sap.ui.commons.ComboBox with name
|
fireChange |
Fire event change to attached listeners. Expects following event parameters:
|
getAccessibilityInfo |
References:
|
getDisplaySecondaryValues |
Gets current value of property displaySecondaryValues. Indicates whether the Default value is |
getF4ButtonDomRef |
Returns the DomRef which represents the icon for value help. Could be overwritten in child-classes |
getItems |
Gets content of aggregation items.
|
getListBox |
ID of the element which is the current target of the association listBox, or |
getMaxPopupItems |
Gets current value of property maxPopupItems. Defines the number of items that shall be displayed at once. If the overall number of items is higher than this setting, a scrollbar is provided. Default value is |
sap.ui.commons.ComboBox.getMetadata |
Returns a metadata object for class sap.ui.commons.ComboBox. |
getSelectedItemId |
Gets current value of property selectedItemId. Id of the selected item. If the value has no corresponding item, the If the |
getSelectedKey |
Gets current value of property selectedKey. Key of the selected item. If the value has no corresponding item the key is empty. If duplicate keys exists the first item matching the key is used. If the key is set to a not existing value it will not be changed. |
indexOfItem |
Checks for the provided |
insertItem |
Inserts a item into the aggregation items. |
onsapenter |
Handle sapenter pseudo events on the control |
onsapescape |
Handle sapescape pseudo events on the control |
onsaphide |
Handle saphide pseudo events on the control |
onsapnextmodifiers |
Handle sapnextmodifiers pseudo events on the control if in toolbar prevent item navigation if popup is opened. |
onsapshow |
Handle sapshow pseudo events on the control |
removeAllItems |
Removes all the controls from the aggregation items. Additionally, it unregisters them from the hosting UIArea. |
removeItem |
Removes a item from the aggregation items. |
setDisplaySecondaryValues |
Sets a new value for property displaySecondaryValues. Indicates whether the When called with a value of Default value is |
setListBox |
Sets the associated listBox. |
setMaxPopupItems |
Sets a new value for property maxPopupItems. Defines the number of items that shall be displayed at once. If the overall number of items is higher than this setting, a scrollbar is provided. When called with a value of Default value is |
setSelectedItemId |
Sets a new value for property selectedItemId. Id of the selected item. If the value has no corresponding item, the If the When called with a value of |
setSelectedKey |
Sets a new value for property selectedKey. Key of the selected item. If the value has no corresponding item the key is empty. If duplicate keys exists the first item matching the key is used. If the key is set to a not existing value it will not be changed. When called with a value of |
unbindItems |
Unbinds aggregation items from model data. |
Compares the previous value with the current value and fires the "Change" event if the ComboBox is editable and the value has changed or whether the value has been changed e.g. via up/down or auto-complete feature
Param | Type | DefaultValue | Description |
---|---|---|---|
oEvent | jQuery.Event |
The event object. |
|
bImmediate | boolean |
indicate whether the check should happen immediately or delayed (e.g. to avoid focusout / click double event processing) |
Adds some item to the aggregation items.
Param | Type | DefaultValue | Description |
---|---|---|---|
oItem | sap.ui.core.ListItem |
The item to add; if empty, nothing is inserted |
Binds aggregation items to model data.
See ManagedObject.bindAggregation for a detailed description of the possible properties of oBindingInfo
.
Param | Type | DefaultValue | Description |
---|---|---|---|
oBindingInfo | sap.ui.base.ManagedObject.AggregationBindingInfo |
The binding information |
Creates a new subclass of class sap.ui.commons.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.ui.commons.TextField.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 |
Fire event change to attached listeners.
Expects following event parameters:
string
The new / changed value of the textfield.sap.ui.core.ListItem
selected item Param | Type | DefaultValue | Description |
---|---|---|---|
mArguments | object |
the arguments to pass along with the event. |
Gets current value of property displaySecondaryValues.
Indicates whether the additionalText
property that is available for sap.ui.core.ListItem
shall be displayed in the list.
Default value is false
.
Returns the DomRef which represents the icon for value help. Could be overwritten in child-classes
Gets content of aggregation items.
ListItems
(see sap.ui.core.ListBox
) that shall be displayed in the list.
Gets current value of property maxPopupItems.
Defines the number of items that shall be displayed at once. If the overall number of items is higher than this setting, a scrollbar is provided.
Default value is 10
.
Gets current value of property selectedItemId.
Id of the selected item. If the value has no corresponding item, the selectedItemId
is empty.
If the selectedItemId
is set to a not existing item, it will not be changed.
Gets current value of property selectedKey.
Key of the selected item.
If the value has no corresponding item the key is empty.
If duplicate keys exists the first item matching the key is used.
If the key is set to a not existing value it will not be changed.
Checks for the provided sap.ui.core.ListItem
in the aggregation items. and returns its index if found or -1 otherwise.
Param | Type | DefaultValue | Description |
---|---|---|---|
oItem | sap.ui.core.ListItem |
The item whose index is looked for |
Inserts a item into the aggregation items.
Param | Type | DefaultValue | Description |
---|---|---|---|
oItem | sap.ui.core.ListItem |
The item to insert; if empty, nothing is inserted |
|
iIndex | int |
The |
Handle sapenter pseudo events on the control
Param | Type | DefaultValue | Description |
---|---|---|---|
oEvent | jQuery.Event |
The event object. |
Handle sapescape pseudo events on the control
Param | Type | DefaultValue | Description |
---|---|---|---|
oEvent | jQuery.Event |
The event object. |
Handle saphide pseudo events on the control
Param | Type | DefaultValue | Description |
---|---|---|---|
oEvent | jQuery.Event |
The event object. |
Handle sapnextmodifiers pseudo events on the control if in toolbar prevent item navigation if popup is opened.
Param | Type | DefaultValue | Description |
---|---|---|---|
oEvent | jQuery.Event |
The event object. |
Handle sapshow pseudo events on the control
Param | Type | DefaultValue | Description |
---|---|---|---|
oEvent | jQuery.Event |
The event object. |
Removes all the controls from the aggregation items.
Additionally, it unregisters them from the hosting UIArea.
Removes a item from the aggregation items.
Param | Type | DefaultValue | Description |
---|---|---|---|
vItem | int string sap.ui.core.ListItem |
The item to remove or its index or id |
Sets a new value for property displaySecondaryValues.
Indicates whether the additionalText
property that is available for sap.ui.core.ListItem
shall be displayed in the list.
When called with a value of null
or undefined
, the default value of the property will be restored.
Default value is false
.
Param | Type | DefaultValue | Description |
---|---|---|---|
bDisplaySecondaryValues | boolean | false |
New value for property |
Sets the associated listBox.
Param | Type | DefaultValue | Description |
---|---|---|---|
oListBox | sap.ui.core.ID sap.ui.commons.ListBox |
ID of an element which becomes the new target of this listBox association; alternatively, an element instance may be given |
Sets a new value for property maxPopupItems.
Defines the number of items that shall be displayed at once. If the overall number of items is higher than this setting, a scrollbar is provided.
When called with a value of null
or undefined
, the default value of the property will be restored.
Default value is 10
.
Param | Type | DefaultValue | Description |
---|---|---|---|
iMaxPopupItems | int | 10 |
New value for property |
Sets a new value for property selectedItemId.
Id of the selected item. If the value has no corresponding item, the selectedItemId
is empty.
If the selectedItemId
is set to a not existing item, it will not be changed.
When called with a value of null
or undefined
, the default value of the property will be restored.
Param | Type | DefaultValue | Description |
---|---|---|---|
sSelectedItemId | string |
New value for property |
Sets a new value for property selectedKey.
Key of the selected item.
If the value has no corresponding item the key is empty.
If duplicate keys exists the first item matching the key is used.
If the key is set to a not existing value it will not be changed.
When called with a value of null
or undefined
, the default value of the property will be restored.
Param | Type | DefaultValue | Description |
---|---|---|---|
sSelectedKey | string |
New value for property |