Search code examples
sapui5

How to prevent multi selection on SmartFilterBar?


I have the following SmartFilterBar: enter image description here

As you can see on the input field, multi selection is possible. How can I prevent multi selection on the field?

I tried:

<smartFilterBar:ControlConfiguration key="ClassType" filterType="smartFilterBar:FilterType.single" visibleInAdvancedArea="true" preventInitialDataFetchInValueHelpDialog="false"></smartFilterBar:ControlConfiguration>
<smartFilterBar:ControlConfiguration key="ClassNum" filterType="smartFilterBar:FilterType.single" visibleInAdvancedArea="true" preventInitialDataFetchInValueHelpDialog="false"></smartFilterBar:ControlConfiguration> 

But it does not work.


Solution

  • There is an annotation which controls this. See this.

       <Annotation Term="com.sap.vocabularies.Common.v1.FilterExpressionRestrictions" >
      <Collection>
         <Record>
            <PropertyValue Property="Property" PropertyPath="Customer" />
            <PropertyValue Property="AllowedExpressions" EnumMember="com.sap.vocabularies.Common.v1.FilterExpressionType/SingleValue" />
         </Record>
         <Record>
            <PropertyValue Property="Property" PropertyPath="CompanyCode" />
            <PropertyValue Property="AllowedExpressions" EnumMember="com.sap.vocabularies.Common.v1.FilterExpressionType/SingleValue" />
         </Record>
      </Collection>
    

    Refer https://sapui5.hana.ondemand.com/sdk/#/api/sap.ui.comp.smartfilterbar.SmartFilterBar/annotations/Summary and search for 'FilterExpressionType' for more detail.