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(mArguments?)Fires event search to attached listeners.
fireSuggest(mArguments?)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:
{string}sId? ID for the new control, generated automatically if no ID is given
{object}mSettings? Initial settings for the new control
Deprecated:
Since version 1.38. Instead, use the sap.m.SearchField control.
Event Detail
search(oControlEvent)
Event which is fired when the user triggers a search
Parameters:
{sap.ui.base.Event}oControlEvent
{sap.ui.base.EventProvider}oControlEvent.getSource
{object}oControlEvent.getParameters
{string}oControlEvent.getParameters.query The search query
suggest(oControlEvent)
Event which is fired when new suggest values are required.
Parameters:
{sap.ui.base.Event}oControlEvent
{sap.ui.base.EventProvider}oControlEvent.getSource
{object}oControlEvent.getParameters
{string}oControlEvent.getParameters.value The 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:
{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.ui.commons.SearchField.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.ui.commons.SearchField.
Returns:
{sap.ui.base.Metadata} Metadata object describing this class
addAriaDescribedBy(vAriaDescribedBy): sap.ui.commons.SearchField
Adds some ariaDescribedBy into the association ariaDescribedBy.
Parameters:
{string|sap.ui.core.Control}vAriaDescribedBy the ariaDescribedBy to add; if empty, nothing is inserted
Returns:
{sap.ui.commons.SearchField} Reference to this in order to allow method chaining
addAriaLabelledBy(vAriaLabelledBy): sap.ui.commons.SearchField
Adds some ariaLabelledBy into the association ariaLabelledBy.
Parameters:
{string|sap.ui.core.Control}vAriaLabelledBy the ariaLabelledBy to add; if empty, nothing is inserted
Returns:
{sap.ui.commons.SearchField} Reference 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:
{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.ui.commons.SearchField itself
Returns:
{sap.ui.commons.SearchField} Reference 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:
{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.ui.commons.SearchField itself
Returns:
{sap.ui.commons.SearchField} Reference 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.SearchField} Reference 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:
{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.ui.commons.SearchField} Reference 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:
{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.ui.commons.SearchField} Reference to this in order to allow method chaining
fireSearch(mArguments?): sap.ui.commons.SearchField
Fires event search to attached listeners.

Expects the following event parameters:

  • query of type stringThe search query
Parameters:
{Map}mArguments? The arguments to pass along with the event
Returns:
{sap.ui.commons.SearchField} Reference to this in order to allow method chaining
fireSuggest(mArguments?): sap.ui.commons.SearchField
Fires event suggest to attached listeners.

Expects the following event parameters:

  • value of type stringThe value for which suggestions are required.
Parameters:
{Map}mArguments? The arguments to pass along with the event
Returns:
{sap.ui.commons.SearchField} Reference to this in order to allow method chaining
getAriaDescribedBy(): sap.ui.core.Control[]
Returns array of IDs of the elements which are the current targets of the association ariaDescribedBy.
Returns:
{sap.ui.core.Control[]}
getAriaLabelledBy(): sap.ui.core.Control[]
Returns array of IDs of the elements which are the current targets of the association ariaLabelledBy.
Returns:
{sap.ui.core.Control[]}
getEditable(): boolean
Gets current value of property editable.

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

Default value is true.

Returns:
{boolean} Value 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.

Since:
1.10.3
Returns:
{boolean} Value of property enableCache
getEnableClear(): boolean
Gets current value of property enableClear.

Defines whether the clear functionality shall be active

Default value is false.

Returns:
{boolean} Value 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:
{boolean} Value 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:
{boolean} Value 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:
{boolean} Value 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:
{int} Value 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:
{int} Value 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:
{int} Value of property maxSuggestionItems
getPlaceholder(): string
Gets current value of property placeholder.

Placeholder for the input field.

Default value is .

Since:
1.32
Returns:
{string} Value of property placeholder
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:
{boolean} Value 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:
{boolean} Value 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:
{int} Value 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.TextAlign} Value of property textAlign
getValue(): string
Gets current value of property value.

Text that shall be displayed within the search field

Default value is .

Returns:
{string} Value 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.

Since:
1.32
Returns:
{sap.ui.core.ValueState} Value of property valueState
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:
{int} Value of property visibleItemCount
getWidth(): sap.ui.core.CSSSize
Gets current value of property width.

Control width in CSS-size

Returns:
{sap.ui.core.CSSSize} Value of property width
removeAllAriaDescribedBy(): sap.ui.core.Control[]
Removes all the controls in the association named ariaDescribedBy.
Returns:
{sap.ui.core.Control[]} An array of the removed elements (might be empty)
removeAllAriaLabelledBy(): sap.ui.core.Control[]
Removes all the controls in the association named ariaLabelledBy.
Returns:
{sap.ui.core.Control[]} An array of the removed elements (might be empty)
removeAriaDescribedBy(vAriaDescribedBy): sap.ui.core.Control
Removes an ariaDescribedBy from the association named ariaDescribedBy.
Parameters:
{int|string|sap.ui.core.Control}vAriaDescribedBy The ariaDescribedByto be removed or its index or ID
Returns:
{sap.ui.core.Control} the removed ariaDescribedBy or null
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
Returns:
{sap.ui.core.Control} the 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:
{boolean}bEditable New value for property editable
Returns:
{sap.ui.commons.SearchField} Reference 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:
{boolean}bEnableCache New value for property enableCache
Since:
1.10.3
Returns:
{sap.ui.commons.SearchField} Reference to this in order to allow method chaining
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:
{boolean}bEnableClear New value for property enableClear
Returns:
{sap.ui.commons.SearchField} Reference 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:
{boolean}bEnabled New value for property enabled
Returns:
{sap.ui.commons.SearchField} Reference 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:
{boolean}bEnableFilterMode New value for property enableFilterMode
Returns:
{sap.ui.commons.SearchField} Reference 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:
{boolean}bEnableListSuggest New value for property enableListSuggest
Returns:
{sap.ui.commons.SearchField} Reference 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:
{int}iMaxHistoryItems New value for property maxHistoryItems
Returns:
{sap.ui.commons.SearchField} Reference 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:
{int}iMaxLength New value for property maxLength
Returns:
{sap.ui.commons.SearchField} Reference 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:
{int}iMaxSuggestionItems New value for property maxSuggestionItems
Returns:
{sap.ui.commons.SearchField} Reference 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:
{string}sPlaceholder New value for property placeholder
Since:
1.32
Returns:
{sap.ui.commons.SearchField} Reference to this in order to allow method chaining
setSearchProvider(oSearchProvider): sap.ui.commons.SearchField
Sets the aggregated searchProvider.
Parameters:
{sap.ui.core.search.SearchProvider}oSearchProvider The searchProvider to set
Returns:
{sap.ui.commons.SearchField} Reference 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:
{boolean}bShowExternalButton New value for property showExternalButton
Returns:
{sap.ui.commons.SearchField} Reference 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:
{boolean}bShowListExpander New value for property showListExpander
Returns:
{sap.ui.commons.SearchField} Reference 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:
{int}iStartSuggestion New value for property startSuggestion
Returns:
{sap.ui.commons.SearchField} Reference 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.TextAlign}sTextAlign New value for property textAlign
Returns:
{sap.ui.commons.SearchField} Reference 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:
{string}sValue New value for property value
Returns:
{sap.ui.commons.SearchField} Reference 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.ValueState}sValueState New value for property valueState
Since:
1.32
Returns:
{sap.ui.commons.SearchField} Reference to this in order to allow method chaining
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:
{int}iVisibleItemCount New value for property visibleItemCount
Returns:
{sap.ui.commons.SearchField} Reference 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.CSSSize}sWidth New value for property width
Returns:
{sap.ui.commons.SearchField} Reference 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:
{string}sSSuggestValue The value which was provided in the corresponding suggest event (parameter 'value')
{string[]}aASuggestions The list of suggestions belonging to the suggest value