Class sap.ui.comp.smartfilterbar.SmartFilterBarModule: sap/ui/comp/smartfilterbar/SmartFilterBar
The SmartFilterBar control uses the OData metadata of an entity in order to create a filter bar.
Whether a field is visible on the filter bar, supports type-ahead and value help, for example, is automatically determined. When you use control configurations and group configurations it is possible to configure the filter bar and adapt it according to your needs.
Note:
Most of the attributes/properties are not dynamic and cannot be changed once the control has been initialized.
A detailed description of the OData annotations handled by this control is available here.
Annotation Limitations: Qualifier support for entity types is limited for this control.
sClassName
and enriches it with the information contained in oClassInfo
.controlConfiguration
.groupConfiguration
.fnFunction
to the pendingChange
event of this sap.ui.comp.smartfilterbar.SmartFilterBar
.controlConfiguration
.groupConfiguration
.fnFunction
from the pendingChange
event of this sap.ui.comp.smartfilterbar.SmartFilterBar
.smartVariant
, or null
.sap.ui.comp.smartfilterbar.ControlConfiguration
in the aggregation controlConfiguration
.sap.ui.comp.smartfilterbar.GroupConfiguration
in the aggregation groupConfiguration
.controlConfiguration
.groupConfiguration
.controlConfiguration
.groupConfiguration
.EntitySet
Defines whether a Property
can be used for filtering data.EntityType
Describes the arrangement of a code value and its text.Property
Defines whether the filter is visible.Property,Parameter
Contains annotations that provide information for rendering a ValueHelpList
that are set on the Property
.Property,PropertyPath
A short, human-readable text suitable for the filter's name.Property,Parameter
A short, human-readable text suitable for the filter's name.EntitySet
Defines the filter field as mandatory filter.EntitySet
Defines whether multiple values can be used in a single filter.EntitySet
Restricts the filter to only one single value entry.EntitySet
Restricts the filter to specify an interval, for example, a date interval for filtering the data present between the given dates. 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
- entityType : string
- resourceUri : string
- basicSearchFieldName : string
- enableBasicSearch : boolean (default: false)
- Aggregations
- controlConfiguration : sap.ui.comp.smartfilterbar.ControlConfiguration[]
- groupConfiguration : sap.ui.comp.smartfilterbar.GroupConfiguration[]
- Events
- pendingChange : fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject]
In addition, all settings applicable to the base type sap.ui.comp.filterbar.FilterBar can be used as well.
{string} | sId? | id for the new control, generated automatically if no id is given |
{object} | mSettings? | initial settings for the new control |
{sap.ui.base.Event} | oControlEvent | |
{sap.ui.base.EventProvider} | oControlEvent.getSource | |
{object} | oControlEvent.getParameters |
- Since:
- 1.36
sClassName
and enriches it with the information contained in oClassInfo
. oClassInfo
might contain the same kind of information as described in sap.ui.comp.filterbar.FilterBar.extend.
{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 |
{function} | Created class / constructor function |
{sap.ui.base.Metadata} | Metadata object describing this class |
controlConfiguration
. {sap.ui.comp.smartfilterbar.ControlConfiguration} | oControlConfiguration | the controlConfiguration to add; if empty, nothing is inserted |
{sap.ui.comp.smartfilterbar.SmartFilterBar} | Reference to this in order to allow method chaining |
{string} | sKey | The key like specified in the OData metadata |
groupConfiguration
. {sap.ui.comp.smartfilterbar.GroupConfiguration} | oGroupConfiguration | the groupConfiguration to add; if empty, nothing is inserted |
{sap.ui.comp.smartfilterbar.SmartFilterBar} | Reference to this in order to allow method chaining |
{object} | oVariant | The variant that must be applied. oVariant must contain a valid JSON object. |
fnFunction
to the pendingChange
event of this sap.ui.comp.smartfilterbar.SmartFilterBar
. 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.comp.smartfilterbar.SmartFilterBar
itself.
This event is fired after the pending state of the FilterBar control changes.
{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.comp.smartfilterbar.SmartFilterBar itself |
- Since:
- 1.36
{sap.ui.comp.smartfilterbar.SmartFilterBar} | Reference to this in order to allow method chaining |
controlConfiguration
. {sap.ui.comp.smartfilterbar.SmartFilterBar} | Reference to this in order to allow method chaining |
groupConfiguration
. {sap.ui.comp.smartfilterbar.SmartFilterBar} | Reference to this in order to allow method chaining |
fnFunction
from the pendingChange
event of this sap.ui.comp.smartfilterbar.SmartFilterBar
. The passed function and listener object must match the ones used for event registration.
{function} | fnFunction | The function to be called, when the event occurs |
{object} | oListener | Context object on which the given function had to be called |
- Since:
- 1.36
{sap.ui.comp.smartfilterbar.SmartFilterBar} | Reference to this in order to allow method chaining |
{object} |
pendingChange
to attached listeners. {Map} | mArguments? | The arguments to pass along with the event |
- Since:
- 1.36
{sap.ui.comp.smartfilterbar.SmartFilterBar} | Reference to this in order to allow method chaining |
{object} | Basic search control |
basicSearchFieldName
. Name of the field that has to be the focus of basic search. This is only relevant for SmartFilterBar in combination with ValueHelpDialog.
{string} | Value of property basicSearchFieldName |
{string} | sKey | The key as present in the OData property name/control configuration |
{object|sap.ui.Control} | The control in the filter bar, if any |
controlConfiguration
. Using control configurations you can add additional configuration to filter fields, for example set custom labels, change the order of fields, or change the filter field control type. Note: Changing the values here after the SmartFilter is initialized (initialise event was fired) has no effect.
{sap.ui.comp.smartfilterbar.ControlConfiguration[]} |
enableBasicSearch
. Enables basic search field in the SmartFilterBar control. This must only be enabled for entities that support such search behavior.
Default value is false
.
{boolean} | Value of property enableBasicSearch |
entityType
. The OData entity type whose metadata is used to create the SmartFilterBar. Note: Changing this value after the SmartFilterBar is initialized (initialise event was fired) has no effect.
{string} | Value of property entityType |
{boolean} | bAllFilterData | Also include empty/invisible fields filter data |
{object} | The JSON data in the filter bar |
{boolean} | bAllFilterData | Also include empty/invisible fields filter data |
{string} | The JSON data string |
The result of this method can directly be used during aggregation binding or OData read.
{string[]} | aFieldNames? | optional array of field names that filters should be returned, if not given all visible filters are returned |
{sap.ui.model.Filter[]} | array of sap.ui.model.Filter or multi-filters |
groupConfiguration
. Provides the possibility to add additional configuration to groups. Groups are used to show fields in the advanced area of the SmartFilterBar. With additional configuration, you can for example set custom labels or change the order of groups. Note: Changing the values here after the SmartFilter is initialized (initialise event was fired) has no effect.
{sap.ui.comp.smartfilterbar.GroupConfiguration[]} |
{object} | A parameter object containing OData query parameters |
smartVariant
, or null
. - Since:
- 1.38
{sap.ui.comp.smartvariants.SmartVariantManagement} |
sap.ui.comp.smartfilterbar.ControlConfiguration
in the aggregation controlConfiguration
. and returns its index if found or -1 otherwise. {sap.ui.comp.smartfilterbar.ControlConfiguration} | oControlConfiguration | The controlConfiguration whose index is looked for |
{int} | The index of the provided control in the aggregation if found, or -1 otherwise |
sap.ui.comp.smartfilterbar.GroupConfiguration
in the aggregation groupConfiguration
. and returns its index if found or -1 otherwise. {sap.ui.comp.smartfilterbar.GroupConfiguration} | oGroupConfiguration | The groupConfiguration whose index is looked for |
{int} | The index of the provided control in the aggregation if found, or -1 otherwise |
controlConfiguration
. {sap.ui.comp.smartfilterbar.ControlConfiguration} | oControlConfiguration | the controlConfiguration to insert; if empty, nothing is inserted |
{int} | iIndex | the 0 -based index the controlConfiguration should be inserted at; for a negative value of iIndex , the controlConfiguration is inserted at position 0; for a value greater than the current size of the aggregation, the controlConfiguration is inserted at the last position |
{sap.ui.comp.smartfilterbar.SmartFilterBar} | Reference to this in order to allow method chaining |
groupConfiguration
. {sap.ui.comp.smartfilterbar.GroupConfiguration} | oGroupConfiguration | the groupConfiguration to insert; if empty, nothing is inserted |
{int} | iIndex | the 0 -based index the groupConfiguration should be inserted at; for a negative value of iIndex , the groupConfiguration is inserted at position 0; for a value greater than the current size of the aggregation, the groupConfiguration is inserted at the last position |
{sap.ui.comp.smartfilterbar.SmartFilterBar} | Reference to this in order to allow method chaining |
{boolean} | true if at least one FilterItem element of the FilterBar control is pending |
controlConfiguration
. Additionally, it unregisters them from the hosting UIArea.
{sap.ui.comp.smartfilterbar.ControlConfiguration[]} | An array of the removed elements (might be empty) |
groupConfiguration
. Additionally, it unregisters them from the hosting UIArea.
{sap.ui.comp.smartfilterbar.GroupConfiguration[]} | An array of the removed elements (might be empty) |
controlConfiguration
. {int|string|sap.ui.comp.smartfilterbar.ControlConfiguration} | vControlConfiguration | The controlConfigurationto remove or its index or id |
{sap.ui.comp.smartfilterbar.ControlConfiguration} | The removed controlConfiguration or null |
groupConfiguration
. {int|string|sap.ui.comp.smartfilterbar.GroupConfiguration} | vGroupConfiguration | The groupConfigurationto remove or its index or id |
{sap.ui.comp.smartfilterbar.GroupConfiguration} | The removed groupConfiguration or null |
basicSearchFieldName
. Name of the field that has to be the focus of basic search. This is only relevant for SmartFilterBar in combination with ValueHelpDialog.
When called with a value of null
or undefined
, the default value of the property will be restored.
{string} | sBasicSearchFieldName | New value for property basicSearchFieldName |
{sap.ui.comp.smartfilterbar.SmartFilterBar} | Reference to this in order to allow method chaining |
enableBasicSearch
. Enables basic search field in the SmartFilterBar control. This must only be enabled for entities that support such search behavior.
When called with a value of null
or undefined
, the default value of the property will be restored.
Default value is false
.
{boolean} | bEnableBasicSearch | New value for property enableBasicSearch |
{sap.ui.comp.smartfilterbar.SmartFilterBar} | Reference to this in order to allow method chaining |
{string} | sEntityTypeName | type name |
{object} | oJson | The JSON data in the filter bar |
{boolean} | bReplace | Replace existing filter data |
{string} | sJson | The JSON data in the filter bar |
{boolean} | bReplace | Replace existing filter data |
smartVariant
. {sap.ui.comp.smartvariants.SmartVariantManagement} | oSmartVariant | Id of an element which becomes the new target of this smartVariant association; alternatively, an element instance may be given |
- Since:
- 1.38
{sap.ui.comp.smartfilterbar.SmartFilterBar} | Reference to this in order to allow method chaining |
resourceUri
. Optional. The OData service URL. If it is not specified, the service URL from the OData model (this.getModel()) will be used. Note: Changing this value after the SmartFilterBar is initialized (initialise event was fired) has no effect.
- Deprecated:
- Since 1.29. Set an ODataModel as the main model on your control/view instead
{string} | Value of property resourceUri |
{string} | sResourceUri | The URI of the oData service from which the metadata would be read |
- Deprecated:
- Since 1.29. Set an ODataModel as the main model on your control/view instead
Property
can be used for filtering data. All properties are filterable by default. In order to disable filtering capability, these properties must be excluded. Note: Currently only OData v2 annotation is supported by the SmartFilterBar control.
XML Example of OData V4 with Excluded Customer and CompanyCode Properties
<Annotation Term="Org.OData.Capabilities.V1.FilterRestrictions"> <PropertyValue Property="NonFilterableProperties"> <Collection> <PropertyPath>Customer</PropertyPath> <PropertyPath>CompanyCode</PropertyPath> </Collection> </PropertyValue> </Annotation>
For OData v2 the sap:filterable
annotation on the Property
can be used to exclude properties from filtering.
<Property Name="Customer" ... sap:filterable="false"/> <Property Name="CompanyCode" ... sap:filterable="false"/>
Refer OData v4 annotations for details about annotations.
EntitySet |
filterItem/#/value |
- Since:
- 1.28.1
Property
within the same EntityType
. XML Example for OData V4 with CompanyName and CompanyCode Properties
<Annotation Term="com.sap.vocabularies.UI.v1.FieldGroup" Qualifier="FieldGroup1"> <Record> <PropertyValue Property="Label" String="my Field Group 1" /> <PropertyValue Property="Data"> <Collection> <PropertyPath>CompanyName</PropertyPath> <PropertyPath>CompanyCode</PropertyPath> </Collection> </PropertyValue> </Record> </Annotation>
Refer OData v4 annotations for details about annotations.
EntityType |
filterGroupItem |
- Since:
- 1.28.1
Property
within the same EntityType
. The enumeration members can have the following values: com.sap.vocabularies.UI.v1.TextArrangementType/TextFirst
The underlying control is represented with the specified description followed by its ID.com.sap.vocabularies.UI.v1.TextArrangementType/TextOnly
The underlying control is represented with the specified description only.
XML Example of OData V4 with EntityType ProductType
<Annotations Target="ProductType"> <Annotation Term="com.sap.vocabularies.UI.v1.TextArrangement" EnumMember="com.sap.vocabularies.UI.v1.TextArrangementType/TextFirst"/> </Annotations>
Refer OData v4 annotations for details about annotations.
EntityType |
text |
- Since:
- 1.32.1
EnumMember
FieldControlType/Hidden
of the FieldControl
annotation for setting the visibility. Note: Currently only FieldControlType/Hidden
is supported for statically hiding the filter fields.
XML Example of OData V4 with Hidden Customer and CompanyCode Properties
<Property Name="Customer"> <Annotation Term="com.sap.vocabularies.Common.v1.FieldControlType/Hidden"/> </Property> <Property Name="CompanyCode"> <Annotation Term="com.sap.vocabularies.Common.v1.FieldControlTpye/Hidden"/> </Property>
For OData v2 the sap:visible
annotation on the Property
can be used to assign visibility.
<Property Name="Customer" ... sap:visible="false"/> <Property Name="CompanyCode" ... sap:visible="false"/>
Refer OData v4 annotations for details about annotations.
Property |
filterItem/#/visible |
- Since:
- 1.32.1
ValueHelpList
that are set on the Property
. Each Parameter on the ValueList
annotation has maximum of two properties: - LocalDataProperty - Path to the property on the local entity that triggered the ValueList.
- ValueListProperty - Path to property in on the ValueList entity.
XML Example of OData V4 with Category having ValueList
<Annotation Term="com.sap.vocabularies.Common.v1.ValueList"> <Record> <PropertyValue Property="Label" String="Category" /> <PropertyValue Property="CollectionPath" String="Category" /> <PropertyValue Property="SearchSupported" Bool="true" /> <PropertyValue Property="Parameters"> <Collection> <Record Type="com.sap.vocabularies.Common.v1.ValueListParameterOut"> <PropertyValue Property="LocalDataProperty" PropertyPath="Category" /> <PropertyValue Property="ValueListProperty" String="Description" /> </Record> <Record Type="com.sap.vocabularies.Common.v1.ValueListParameterDisplayOnly"> <PropertyValue Property="ValueListProperty" String="CategoryName" /> </Record> </Collection> </Record> </Annotation>
Refer OData v4 annotations for details about annotations.
Property |
Parameter |
filterItem/#/fieldHelp |
- Since:
- 1.28.1
com.sap.vocabularies.Common.v1.Label
annotation is defined on the Property
. If the com.sap.vocabularies.Common.v1.Label
annotation is given, it has precedence. If none of the annotations are given, then the label will be the Property name. XML Example for OData V4 where CustomerName is the Label assigned to Customer
<Property Name="Customer" /> <Annotation Term="com.sap.vocabularies.Common.v1.Label" Path="Customer" String="Customer Name"/>
For OData v2 the sap:label
annotation on the Property
can be used to define the label of the column.
<Property Name="Customer" ... sap:label="Customer Name"/>
Refer OData v4 annotations for details about annotations.
Property |
PropertyPath |
filterItem/label |
- Since:
- 1.28.1
Label annotation of com.sap.vocabularies.UI.v1.DataFieldAbstract
is defined within com.sap.vocabularies.UI.v1.LineItem
annotation. If the com.sap.vocabularies.Common.v1.Label
annotation is given, it has precedence. If none of the annotations are given, then the label will be the Property name of the column. XML Example for OData V4 where CustomerName is the Label assigned to Customer
<Property Name="Customer">
<Annotation Term="com.sap.vocabularies.Common.v1.Label" Path="CustomerName" />
</Property>
<Property Name="CustomerName" type="Edm.String" />
For OData v2 the sap:label
annotation on the Property
can be used to define the label of the column.
<Property Name="Customer" ... sap:label="My Customer"/>
Refer OData v4 annotations for details about annotations.
Target Type:
Property |
Parameter |
Applies to Aggregation/Property:
filterItem/label |
Since:
1.28.1
FilterRestrictions/RequiredProperties(Org.OData.Capabilities.V1)Defines the filter field as mandatory filter. Filter fields having this annotation must be a part of the $filter
request sent to the back-end. Note: Currently only OData v2 annotation is supported by the SmartFilterBar
control.
XML Example of OData V4 with Required CompanyCode Filter
<Annotation Term="Org.OData.Capabilities.V1.FilterRestrictions">
<Record>
<PropertyValue Property="RequiresFilter" Bool="true"/>
<PropertyValue Property="RequiredProperties">
<Collection>
<PropertyPath>CompanyCode</PropertyPath>
</Collection>
</PropertyValue>
</Record>
</Annotation>
For OData v2 the sap:required-in-filter
annotation on the Property
can be used for setting the filter as a mandatory filter field.
<Property Name="Customer" ... sap:required-in-filter="true"/>
<Property Name="CompanyCode" ... sap:required-in-filter="true"/>
Refer OData v4 annotations for details about annotations. Target Type: EntitySet
Applies to Aggregation/Property: filterItem/#/value
- Since:
- 1.28.1
FilterExpressionRestrictions/MultiValue(com.sap.vocabularies.Common.v1)Defines whether multiple values can be used in a single filter. With multi-value filtering, more that one "equals" condition can be defined for filtering the data. Note: Currently only OData v2 annotation is supported by the SmartFilterBar
control.
XML Example of OData V4 with Multi-value Customer and CompanyCode Properties
<Annotation Term="com.sap.vocabularies.Common.v1.FilterExpressionRestriction"
EnumMember="com.sap.vocabularies.Common.v1.FilterExpressionType/MultiValue>
<Record>
<Collection>
<PropertyPath>Customer</PropertyPath>
<PropertyPath>CompanyCode</PropertyPath>
</Collection>
</Record>
</Annotation>
For OData v2 the sap:filter-restriction="multi-value"
annotation on the Property
can be used for rendering multi-value filter field.
<Property Name="Customer" ... sap:filter-restriction="multi-value"/>
<Property Name="CompanyCode" ... sap:filter-restriction="multi-value"/>
Refer OData v4 annotations for details about annotations. Target Type: EntitySet
Applies to Aggregation/Property: filterItem/#/input
- Since:
- 1.28.1
FilterExpressionRestrictions/SingleValue(com.sap.vocabularies.Common.v1)Restricts the filter to only one single value entry. With single-value filtering, you cannot define more than one "equals" condition for filtering the data. Note: Currently only OData v2 annotation is supported by the SmartFilterBar
control.
XML Example of OData V4 with Single-value Customer and CompanyCode Properties
<Annotation Term="com.sap.vocabularies.Common.v1.FilterExpressionRestriction"
EnumMember="com.sap.vocabularies.Common.v1.FilterExpressionType/SingleValue>
<Record>
<Collection>
<PropertyPath>Customer</PropertyPath>
<PropertyPath>CompanyCode</PropertyPath>
</Collection>
</Record>
</Annotation>
For OData v2 the sap:filter-restriction="single-value"
annotation on the Property
can be used for rendering a single-value filter field.
<Property Name="Customer" ... sap:filter-restriction="single-value"/>
<Property Name="CompanyCode" ... sap:filter-restriction="single-value"/>
Refer OData v4 annotations for details about annotations. Target Type: EntitySet
Applies to Aggregation/Property: filterItem/#/input
- Since:
- 1.28.1
FilterExpressionRestrictions/SingleInterval(com.sap.vocabularies.Common.v1)Restricts the filter to specify an interval, for example, a date interval for filtering the data present between the given dates. Note: Currently only OData v2 annotation is supported by the SmartFilterBar
control.
XML Example of OData V4 with Interval Restriction on DocumentDate Property
<Annotation Term="com.sap.vocabularies.Common.v1.FilterExpressionRestriction"
EnumMember="com.sap.vocabularies.Common.v1.FilterExpressionType/SingleInterval>
<Record>
<Collection>
<PropertyPath>DocumentDate</PropertyPath>
</Collection>
</Record>
</Annotation>
For OData v2 the sap:filter-restriction="interval"
annotation on the Property
can be used for rendering an interval filter field.
<Property Name="DocumentDate" ... sap:filter-restriction="interval"/>
Refer OData v4 annotations for details about annotations. Target Type: EntitySet
Applies to Aggregation/Property: filterItem/#/input
- Since:
- 1.28.1