Show TOC

Smart Filter BarLocate this document in the navigation structure

The sap.ui.comp.smartfilterbar.SmartFilterBar control analyzes the $metadata document of an OData service and renders a FilterBar that can be used to filter a table.

The frequently asked questions section below aims at answering some basic questions that you might have when using the SmartTable control.

Note The code samples in this section reflect examples of possible use cases and might not always be suitable for your purposes. Therefore, we recommend that you do not copy and use them directly.

The SmartFilterBar control is a wrapper control that analyzes the $metadata document of an OData service. It renders a FilterBar control and provides integration with the VariantManagement control that is easy to configure.

$metadata is an XML-based document containing several annotations. These annotations are used to:

  • Determine the type of control (for example, whether a field is shown as MultiInput control or as DatePicker)
  • Enable the Suggest feature
  • Enable ValueHelpDialog

In addition to the $metadata document, you can also have an additional configuration in the XML view. This additional configuration can be either sap.ui.comp.smartfilterbar.ControlConfiguration or sap.ui.comp.smartfilterbar.GroupConfiguration. Using this additional configuration, you can override certain settings from the OData metadata, such as labels, indexes, or the type of control. You can also add custom fields or custom groups to the filter bar that are not part of the OData $metadata document at all.

The FieldGroup annotation is used by the SmartFilterBar control to create a grouping of the fields. The grouping is shown in the filter dialog. Any label specified in this dialog is used to override the default label of the property. Only sap:filterable fields are enabled in the SmartFilterBar control by default (default is true when null).

Multi-value and unrestricted Date fields are supported if the annotation sap:filter-restriction="multi-value" is set for date properties.

For MultiInput filter fields, the MultiLine mode is active.

The SmartFilterBar control supports the Edm.Time OData type. The fields bound to OData properties of this type are represented by the sap.m.TimePicker control. The filter panel of the SmartFilterBar control containing the conditions allows filtering for time types using the TimePicker control.



TypeAhead is not working. When I start typing, no http requests are sent.


Take a look at the $metadata document and make sure there are ValueHelp annotations for this field. The Target attribute must look like this: {Namespace}.{EntityName}/{FieldName}.

Make sure that the namespace in the Target attribute is correct.

Example of a ValueHelp annotation:

<Annotations Target="FAP_VENDOR_LINE_ITEMS_SRV.Item/Creditor" xmlns="">
	<Annotation Term="">
			<PropertyValue Property="CollectionPath" String="Vendors"/>
			<PropertyValue Property="SearchSupported" Bool="true"/>
			<PropertyValue Property="Parameters">
					<Record Type="">
						<PropertyValue Property="LocalDataProperty" PropertyPath="Creditor"/>
						<PropertyValue Property="ValueListProperty" String="VendorID"/>


I have a field Entered on that’s an Input field. It should be a DatePicker.


Take a look at the $metadata document and make sure that the property is of type Edm.DateTime and the property is annotated with sap:display-format="Date".


I tried to set default values for a filter field in the control configuration in JavaScript. These default values don’t have any effect.


The ControlConfiguration and GroupConfiguration are intended to be used to add static configuration in an XML view.

There are three properties that can be set dynamically:
  • visible

  • label

  • visibleInAdvancedArea

All other properties and aggregations are not dynamic. This means they have to be set statically in the XML view, and not dynamically by JavaScript. Any changes made in the ControlConfiguration or GroupConfiguration after the initialise event has been fired do not have any effect.

If you have to set values of a filter field dynamically in JavaScript, you can use the setFilterData API.


The value help dialog for a filter field contains a table with multiple columns. How can I change the order of these columns?


The order of the columns is specified in the OData $metadata document in the ValueHelp annotation.

There is one column for each ValueListParameterInOut or ValueListParameterOut in the related annotation.

The order of the columns is the same as the order of the InOut/Out parameters in the $metadata document. You can’t use configuration in the XML view to change this order. If you want to change the order, you can do it in the OData $metadata document.


I have added custom controls to the SmartFilterBar. If I save a variant and load it again the custom fields are initial. What do I have to do to enable custom fields for variant management?


In general, custom fields cannot be handled automatically by the SmartFilterBar control. You have to implement this in the view’s controller. The SmartFilterBar offers two events that can be used to enable custom fields for variant management:

  • beforeVariantSave
  • afterVariantLoad

You can use the beforeVariantSave event to update the model of the SmartFilterBar with the values from the custom fields. Every value within the model is stored as a variant. The values of custom fields should be stored under the property _CUSTOM, for example, oSmartFilter.setFilterData({_ CUSTOM :{field1:"abc", field2:"123"}});

You can use the event afterVariantLoad to get the values from the model and use them to update the custom filter fields, for example:

oData = oSmartFilter.getFilterData();
var oCustomFieldData = oData["_CUSTOM"];

If both events are handled this way, custom fields are enabled for variant management.


How can I set initial or default data in the SmartFilterBar control?


Static data can be set in the control using ControlConfiguration in the view.xml:

<smartFilterBar:SmartFilterBar id="smartFilterBar" ...>
              <smartFilterBar:ControlConfiguration key="CompanyCode" visible="true" index="3"…>
                            <smartFilterBar:SelectOption low="0001">


How can I set dynamic data as initial or default data in the SmartFilterBar control, for example, for navigation parameters?


Dynamic data can be set as initial or default data in the control by registering to the initialise event and setting JSON/JSONstring using the setFilterData API in your controller.js.

onInitSmartFilter: function(oEvent) { //Assuming that this is the eventhandler registered for the "initialise" event of the SmartFilterBar control in your view.xml
              var    oSmartFilter = oView.byId("smartFilterBar");
              var oTodaysDate = new Date();
              //Sample Data
              var oJSONData = {
                           Company: {
                                  items: [ //MultiInput fields with filter-restriction="multi-value" (Ex: shown as Tokens based on control type)
                                            text:"SAP SE" //Display text on the token --> not used for filtering!
                                      text:"SAP XYZ"
                           SomeDate: { //DateRange field with filter-restriction="interval"
                                  low: oTodaysDate, //Date fields require JavaScript Date objects!
                                  high: oTodaysDate
                           YearInterval: {
                                  low: "2000-2014" //simple input field with filter-restriction="interval" --> text separated by a single "-"
                           Ledger:"0L" //Single-value field --> Plain input
              oSmartFilter.setFilterData(oJSONData); //Data will be updated with existing data in the SmartFilter

Note You can use the setFilterData API to set data in the SmartFilterBar control.


How does the SmartFilterBar determine if a filter has a value assigned to it?


The SmartFilterBar control handles the checks whether values are set for the OData-service-based filters, but has only a limited capability to do the same for custom fields. For checks like this, the custom field provider has to provide a Boolean value (true/false) as an indicator whether a value for the custom field exists via the custom data extension hasValue. If the custom data does not exist, the SmartFilterBar control analyzes if the custom control has either the method getValue or getSelectedKey and by using those tries to determine whether the value exists.

Note The method-based check is not very reliable, since, for example, MultiComboBox provides both methods mentioned, but the actual value is accessed via getSelectedKeys. It is strongly recommended to use the custom data extension for such scenarios. The SmartFilterBar control can only react to an onChange event. Therefore, the application has to set the hasValue custom data while handling the onChange event.
Related Information