Class sap.ui.commons.SearchFieldModule: sap/ui/commons/SearchField

extends Control
implements ToolbarItem

Allows the user to type search queries and to trigger the search. Optionally, suggestions can be added.
Deprecated API:
Since version 1.38. Instead, use the sap.m.SearchField control.
Constructor Summary
new sap.ui.commons.SearchField(sId?, mSettings?)Constructor for a new SearchField.
Event Summary
search(oControlEvent)Event which is fired when the user triggers a search
suggest(oControlEvent)Event which is fired when new suggest values are required.
Events borrowed from class sap.ui.core.Control
Method Summary
sap.ui.commons.SearchField.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.ui.commons.SearchField with name sClassName and enriches it with the information contained in oClassInfo.
sap.ui.commons.SearchField.getMetadata()Returns a metadata object for class sap.ui.commons.SearchField.
addAriaDescribedBy(vAriaDescribedBy)Adds some ariaDescribedBy into the association ariaDescribedBy.
addAriaLabelledBy(vAriaLabelledBy)Adds some ariaLabelledBy into the association ariaLabelledBy.
attachSearch(oData?, fnFunction, oListener?)Attaches event handler fnFunction to the search event of this sap.ui.commons.SearchField.
attachSuggest(oData?, fnFunction, oListener?)Attaches event handler fnFunction to the suggest event of this sap.ui.commons.SearchField.
clearHistory()Clears the history of the control
destroySearchProvider()Destroys the searchProvider in the aggregation searchProvider.
detachSearch(fnFunction, oListener)Detaches event handler fnFunction from the search event of this sap.ui.commons.SearchField.
detachSuggest(fnFunction, oListener)Detaches event handler fnFunction from the suggest event of this sap.ui.commons.SearchField.
fireSearch(mParameters?)Fires event search to attached listeners.
fireSuggest(mParameters?)Fires event suggest to attached listeners.
getAriaDescribedBy()Returns array of IDs of the elements which are the current targets of the association ariaDescribedBy.
getAriaLabelledBy()Returns array of IDs of the elements which are the current targets of the association ariaLabelledBy.
getEditable()Gets current value of property editable.
getEnableCache()Gets current value of property enableCache.
getEnableClear()Gets current value of property enableClear.
getEnabled()Gets current value of property enabled.
getEnableFilterMode()Gets current value of property enableFilterMode.
getEnableListSuggest()Gets current value of property enableListSuggest.
getMaxHistoryItems()Gets current value of property maxHistoryItems.
getMaxLength()Gets current value of property maxLength.
getMaxSuggestionItems()Gets current value of property maxSuggestionItems.
getPlaceholder()Gets current value of property placeholder.
getSearchProvider()Gets content of aggregation searchProvider.
getShowExternalButton()Gets current value of property showExternalButton.
getShowListExpander()Gets current value of property showListExpander.
getStartSuggestion()Gets current value of property startSuggestion.
getTextAlign()Gets current value of property textAlign.
getValue()Gets current value of property value.
getValueState()Gets current value of property valueState.
getVisibleItemCount()Gets current value of property visibleItemCount.
getWidth()Gets current value of property width.
removeAllAriaDescribedBy()Removes all the controls in the association named ariaDescribedBy.
removeAllAriaLabelledBy()Removes all the controls in the association named ariaLabelledBy.
removeAriaDescribedBy(vAriaDescribedBy)Removes an ariaDescribedBy from the association named ariaDescribedBy.
removeAriaLabelledBy(vAriaLabelledBy)Removes an ariaLabelledBy from the association named ariaLabelledBy.
setEditable(bEditable)Sets a new value for property editable.
setEnableCache(bEnableCache)Sets a new value for property enableCache.
setEnableClear(bEnableClear)Sets a new value for property enableClear.
setEnabled(bEnabled)Sets a new value for property enabled.
setEnableFilterMode(bEnableFilterMode)Sets a new value for property enableFilterMode.
setEnableListSuggest(bEnableListSuggest)Sets a new value for property enableListSuggest.
setMaxHistoryItems(iMaxHistoryItems)Sets a new value for property maxHistoryItems.
setMaxLength(iMaxLength)Sets a new value for property maxLength.
setMaxSuggestionItems(iMaxSuggestionItems)Sets a new value for property maxSuggestionItems.
setPlaceholder(sPlaceholder)Sets a new value for property placeholder.
setSearchProvider(oSearchProvider)Sets the aggregated searchProvider.
setShowExternalButton(bShowExternalButton)Sets a new value for property showExternalButton.
setShowListExpander(bShowListExpander)Sets a new value for property showListExpander.
setStartSuggestion(iStartSuggestion)Sets a new value for property startSuggestion.
setTextAlign(sTextAlign)Sets a new value for property textAlign.
setValue(sValue)Sets a new value for property value.
setValueState(sValueState)Sets a new value for property valueState.
setVisibleItemCount(iVisibleItemCount)Sets a new value for property visibleItemCount.
setWidth(sWidth)Sets a new value for property width.
suggest(sSSuggestValue, aASuggestions)Callback function used to provide the suggest values in the handler of the suggest event (only in list suggestion mode)
Constructor Detail
new sap.ui.commons.SearchField(sId?, mSettings?)

Constructor for a new SearchField.

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.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
search(oControlEvent)
Event which is fired when the user triggers a search
Parameters:
sap.ui.base.EventoControlEvent
sap.ui.base.EventProvideroControlEvent.getSource
objectoControlEvent.getParameters
stringoControlEvent.getParameters.queryThe search query
suggest(oControlEvent)
Event which is fired when new suggest values are required.
Parameters:
sap.ui.base.EventoControlEvent
sap.ui.base.EventProvideroControlEvent.getSource
objectoControlEvent.getParameters
stringoControlEvent.getParameters.valueThe value for which suggestions are required.
Method Detail
sap.ui.commons.SearchField.extend(sClassName, oClassInfo?, FNMetaImpl?): function

Creates a new subclass of class sap.ui.commons.SearchField 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.ui.commons.SearchField.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.ui.commons.SearchField.
Returns:
sap.ui.base.MetadataMetadata object describing this class
addAriaDescribedBy(vAriaDescribedBy): sap.ui.commons.SearchField
Adds some ariaDescribedBy into the association ariaDescribedBy.
Parameters:
sap.ui.core.ID|sap.ui.core.ControlvAriaDescribedBythe ariaDescribedBy to add; if empty, nothing is inserted
Returns:
sap.ui.commons.SearchFieldReference to this in order to allow method chaining
addAriaLabelledBy(vAriaLabelledBy): sap.ui.commons.SearchField
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.ui.commons.SearchFieldReference to this in order to allow method chaining
attachSearch(oData?, fnFunction, oListener?): sap.ui.commons.SearchField

Attaches event handler fnFunction to the search event of this sap.ui.commons.SearchField.

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.ui.commons.SearchField itself.

Event which is fired when the user triggers a search

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.ui.commons.SearchField itself
Returns:
sap.ui.commons.SearchFieldReference to this in order to allow method chaining
attachSuggest(oData?, fnFunction, oListener?): sap.ui.commons.SearchField

Attaches event handler fnFunction to the suggest event of this sap.ui.commons.SearchField.

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.ui.commons.SearchField itself.

Event which is fired when new suggest values are required.

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.ui.commons.SearchField itself
Returns:
sap.ui.commons.SearchFieldReference to this in order to allow method chaining
clearHistory(): void
Clears the history of the control
destroySearchProvider(): sap.ui.commons.SearchField
Destroys the searchProvider in the aggregation searchProvider.
Returns:
sap.ui.commons.SearchFieldReference to this in order to allow method chaining
detachSearch(fnFunction, oListener): sap.ui.commons.SearchField

Detaches event handler fnFunction from the search event of this sap.ui.commons.SearchField.

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.ui.commons.SearchFieldReference to this in order to allow method chaining
detachSuggest(fnFunction, oListener): sap.ui.commons.SearchField

Detaches event handler fnFunction from the suggest event of this sap.ui.commons.SearchField.

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.ui.commons.SearchFieldReference to this in order to allow method chaining
fireSearch(mParameters?): sap.ui.commons.SearchField
Fires event search to attached listeners.
Parameters:
objectmParameters?Parameters to pass along with the event
stringmParameters.query?The search query
Returns:
sap.ui.commons.SearchFieldReference to this in order to allow method chaining
fireSuggest(mParameters?): sap.ui.commons.SearchField
Fires event suggest to attached listeners.
Parameters:
objectmParameters?Parameters to pass along with the event
stringmParameters.value?The value for which suggestions are required.
Returns:
sap.ui.commons.SearchFieldReference to this in order to allow method chaining
getAriaDescribedBy(): sap.ui.core.ID[]
Returns array of IDs of the elements which are the current targets of the association ariaDescribedBy.
Returns:
sap.ui.core.ID[]
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[]
getEditable(): boolean

Gets current value of property editable.

Non-editable controls have different colors, depending on custom settings

Default value is true.

Returns:
booleanValue of property editable
getEnableCache(): boolean

Gets current value of property enableCache.

When list suggestion is enabled all suggestions are cached and no suggest event is fired.

Default value is true.

Returns:
booleanValue of property enableCache
Since:
1.10.3
getEnableClear(): boolean

Gets current value of property enableClear.

Defines whether the clear functionality shall be active

Default value is false.

Returns:
booleanValue of property enableClear
getEnabled(): boolean

Gets current value of property enabled.

Disabled fields have different colors, and they can not be focused.

Default value is true.

Returns:
booleanValue of property enabled
getEnableFilterMode(): boolean

Gets current value of property enableFilterMode.

Defines whether the search event should also be fired when the SearchField is empty (like a Filter field) and when the clear button (if activated) is pressed.

Default value is false.

Returns:
booleanValue of property enableFilterMode
getEnableListSuggest(): boolean

Gets current value of property enableListSuggest.

Defines whether a pop up list shall be provided for suggestions

Default value is true.

Returns:
booleanValue of property enableListSuggest
getMaxHistoryItems(): int

Gets current value of property maxHistoryItems.

Maximum number of history items in the suggestion list. 0 displays and stores no history. The history is locally stored on the client. Therefore do not activate this feature when this control handles confidential data.

Default value is 0.

Returns:
intValue of property maxHistoryItems
getMaxLength(): int

Gets current value of property maxLength.

Maximum number of characters. Value '0' means the feature is switched off.

Default value is 0.

Returns:
intValue of property maxLength
getMaxSuggestionItems(): int

Gets current value of property maxSuggestionItems.

Maximum number of suggestion items in the suggestion list.

Default value is 10.

Returns:
intValue of property maxSuggestionItems
getPlaceholder(): string

Gets current value of property placeholder.

Placeholder for the input field.

Default value is .

Returns:
stringValue of property placeholder
Since:
1.32
getSearchProvider(): sap.ui.core.search.SearchProvider

Gets content of aggregation searchProvider.

Search provider instance which handles the suggestions for this SearchField (e.g. Open Search Protocol).

Returns:
sap.ui.core.search.SearchProvider
getShowExternalButton(): boolean

Gets current value of property showExternalButton.

Defines whether an additional search button shall be displayed

Default value is false.

Returns:
booleanValue of property showExternalButton
getShowListExpander(): boolean

Gets current value of property showListExpander.

Defines whether the list expander shall be displayed in the case of an enabled list for suggestions. This feature is deactivated on mobile devices.

Default value is true.

Returns:
booleanValue of property showListExpander
getStartSuggestion(): int

Gets current value of property startSuggestion.

Minimum length of the entered string triggering the suggestion list.

Default value is 3.

Returns:
intValue of property startSuggestion
getTextAlign(): sap.ui.core.TextAlign

Gets current value of property textAlign.

Sets the horizontal alignment of the text

Default value is Begin.

Returns:
sap.ui.core.TextAlignValue of property textAlign
getValue(): string

Gets current value of property value.

Text that shall be displayed within the search field

Default value is .

Returns:
stringValue of property value
getValueState(): sap.ui.core.ValueState

Gets current value of property valueState.

Visualizes warnings or errors related to the input field. Possible values: Warning, Error, Success, None.

Default value is None.

Returns:
sap.ui.core.ValueStateValue of property valueState
Since:
1.32
getVisibleItemCount(): int

Gets current value of property visibleItemCount.

Defines the number of items in the suggestion list that shall be displayed at once. If the overall number of list items is higher than the setting, a scroll bar is provided.

Default value is 20.

Returns:
intValue of property visibleItemCount
getWidth(): sap.ui.core.CSSSize

Gets current value of property width.

Control width in CSS-size

Returns:
sap.ui.core.CSSSizeValue of property width
removeAllAriaDescribedBy(): sap.ui.core.ID[]
Removes all the controls in the association named ariaDescribedBy.
Returns:
sap.ui.core.ID[]An array of the removed elements (might be empty)
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)
removeAriaDescribedBy(vAriaDescribedBy): sap.ui.core.ID
Removes an ariaDescribedBy from the association named ariaDescribedBy.
Parameters:
int|sap.ui.core.ID|sap.ui.core.ControlvAriaDescribedByThe ariaDescribedBy to be removed or its index or ID
Returns:
sap.ui.core.IDThe removed ariaDescribedBy or null
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
setEditable(bEditable): sap.ui.commons.SearchField

Sets a new value for property editable.

Non-editable controls have different colors, depending on custom settings

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

Default value is true.

Parameters:
booleanbEditableNew value for property editable
Returns:
sap.ui.commons.SearchFieldReference to this in order to allow method chaining
setEnableCache(bEnableCache): sap.ui.commons.SearchField

Sets a new value for property enableCache.

When list suggestion is enabled all suggestions are cached and no suggest event is fired.

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

Default value is true.

Parameters:
booleanbEnableCacheNew value for property enableCache
Returns:
sap.ui.commons.SearchFieldReference to this in order to allow method chaining
Since:
1.10.3
setEnableClear(bEnableClear): sap.ui.commons.SearchField

Sets a new value for property enableClear.

Defines whether the clear functionality shall be active

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

Default value is false.

Parameters:
booleanbEnableClearNew value for property enableClear
Returns:
sap.ui.commons.SearchFieldReference to this in order to allow method chaining
setEnabled(bEnabled): sap.ui.commons.SearchField

Sets a new value for property enabled.

Disabled fields have different colors, and they can not be focused.

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.ui.commons.SearchFieldReference to this in order to allow method chaining
setEnableFilterMode(bEnableFilterMode): sap.ui.commons.SearchField

Sets a new value for property enableFilterMode.

Defines whether the search event should also be fired when the SearchField is empty (like a Filter field) and when the clear button (if activated) is pressed.

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

Default value is false.

Parameters:
booleanbEnableFilterModeNew value for property enableFilterMode
Returns:
sap.ui.commons.SearchFieldReference to this in order to allow method chaining
setEnableListSuggest(bEnableListSuggest): sap.ui.commons.SearchField

Sets a new value for property enableListSuggest.

Defines whether a pop up list shall be provided for suggestions

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

Default value is true.

Parameters:
booleanbEnableListSuggestNew value for property enableListSuggest
Returns:
sap.ui.commons.SearchFieldReference to this in order to allow method chaining
setMaxHistoryItems(iMaxHistoryItems): sap.ui.commons.SearchField

Sets a new value for property maxHistoryItems.

Maximum number of history items in the suggestion list. 0 displays and stores no history. The history is locally stored on the client. Therefore do not activate this feature when this control handles confidential data.

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

Default value is 0.

Parameters:
intiMaxHistoryItemsNew value for property maxHistoryItems
Returns:
sap.ui.commons.SearchFieldReference to this in order to allow method chaining
setMaxLength(iMaxLength): sap.ui.commons.SearchField

Sets a new value for property maxLength.

Maximum number of characters. Value '0' means the feature is switched off.

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

Default value is 0.

Parameters:
intiMaxLengthNew value for property maxLength
Returns:
sap.ui.commons.SearchFieldReference to this in order to allow method chaining
setMaxSuggestionItems(iMaxSuggestionItems): sap.ui.commons.SearchField

Sets a new value for property maxSuggestionItems.

Maximum number of suggestion items in the suggestion list.

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

Default value is 10.

Parameters:
intiMaxSuggestionItemsNew value for property maxSuggestionItems
Returns:
sap.ui.commons.SearchFieldReference to this in order to allow method chaining
setPlaceholder(sPlaceholder): sap.ui.commons.SearchField

Sets a new value for property placeholder.

Placeholder for the input field.

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

Default value is .

Parameters:
stringsPlaceholderNew value for property placeholder
Returns:
sap.ui.commons.SearchFieldReference to this in order to allow method chaining
Since:
1.32
setSearchProvider(oSearchProvider): sap.ui.commons.SearchField
Sets the aggregated searchProvider.
Parameters:
sap.ui.core.search.SearchProvideroSearchProviderThe searchProvider to set
Returns:
sap.ui.commons.SearchFieldReference to this in order to allow method chaining
setShowExternalButton(bShowExternalButton): sap.ui.commons.SearchField

Sets a new value for property showExternalButton.

Defines whether an additional search button shall be displayed

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

Default value is false.

Parameters:
booleanbShowExternalButtonNew value for property showExternalButton
Returns:
sap.ui.commons.SearchFieldReference to this in order to allow method chaining
setShowListExpander(bShowListExpander): sap.ui.commons.SearchField

Sets a new value for property showListExpander.

Defines whether the list expander shall be displayed in the case of an enabled list for suggestions. This feature is deactivated on mobile devices.

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

Default value is true.

Parameters:
booleanbShowListExpanderNew value for property showListExpander
Returns:
sap.ui.commons.SearchFieldReference to this in order to allow method chaining
setStartSuggestion(iStartSuggestion): sap.ui.commons.SearchField

Sets a new value for property startSuggestion.

Minimum length of the entered string triggering the suggestion list.

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

Default value is 3.

Parameters:
intiStartSuggestionNew value for property startSuggestion
Returns:
sap.ui.commons.SearchFieldReference to this in order to allow method chaining
setTextAlign(sTextAlign): sap.ui.commons.SearchField

Sets a new value for property textAlign.

Sets the horizontal alignment of the text

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

Default value is Begin.

Parameters:
sap.ui.core.TextAlignsTextAlignNew value for property textAlign
Returns:
sap.ui.commons.SearchFieldReference to this in order to allow method chaining
setValue(sValue): sap.ui.commons.SearchField

Sets a new value for property value.

Text that shall be displayed within the search field

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

Default value is .

Parameters:
stringsValueNew value for property value
Returns:
sap.ui.commons.SearchFieldReference to this in order to allow method chaining
setValueState(sValueState): sap.ui.commons.SearchField

Sets a new value for property valueState.

Visualizes warnings or errors related to the input field. Possible values: Warning, Error, Success, None.

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

Default value is None.

Parameters:
sap.ui.core.ValueStatesValueStateNew value for property valueState
Returns:
sap.ui.commons.SearchFieldReference to this in order to allow method chaining
Since:
1.32
setVisibleItemCount(iVisibleItemCount): sap.ui.commons.SearchField

Sets a new value for property visibleItemCount.

Defines the number of items in the suggestion list that shall be displayed at once. If the overall number of list items is higher than the setting, a scroll bar is provided.

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

Default value is 20.

Parameters:
intiVisibleItemCountNew value for property visibleItemCount
Returns:
sap.ui.commons.SearchFieldReference to this in order to allow method chaining
setWidth(sWidth): sap.ui.commons.SearchField

Sets a new value for property width.

Control width in CSS-size

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

Parameters:
sap.ui.core.CSSSizesWidthNew value for property width
Returns:
sap.ui.commons.SearchFieldReference to this in order to allow method chaining
suggest(sSSuggestValue, aASuggestions): void
Callback function used to provide the suggest values in the handler of the suggest event (only in list suggestion mode)
Parameters:
stringsSSuggestValueThe value which was provided in the corresponding suggest event (parameter 'value')
string[]aASuggestionsThe list of suggestions belonging to the suggest value