You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何为UI5 SmartFilter的值帮助添加「定义条件」功能?

问题:为UI5 SmartFilter值帮助添加排除选项的缺失配置

应用UI5版本:1.44

我增强了标准OData服务,为其中一个实体添加了自定义字段ZBrandId,并创建注解使其在UI5 SmartFilter中启用值帮助。

配置的注解如下:

<Property Name="ZBrandId" Type="Edm.String" Nullable="false" MaxLength="60" sap:filter-restriction="multi-value" sap:label="Marke" sap:creatable="false" sap:updatable="false" sap:sortable="false"/> 
<Annotations xmlns="http://docs.oasis-open.org/odata/ns/edm" Target="DMF.PROD_MD_SRV.ProductFilter/ZBrandId">
    <Annotation Term="com.sap.vocabularies.Common.v1.ValueList">
        <Record>
            <PropertyValue Property="CollectionPath" String="SH_HZCA_H_BRAND_CDS"/>
            <PropertyValue Property="SearchSupported" Bool="true"/>
            <PropertyValue Property="Parameters">
                <Collection>
                    <Record Type="com.sap.vocabularies.Common.v1.ValueListParameterInOut">
                        <PropertyValue Property="LocalDataProperty" PropertyPath="ZBrandId"/>
                        <PropertyValue Property="ValueListProperty" String="BRAND_ID"/>
                    </Record>
                    <Record Type="com.sap.vocabularies.Common.v1.ValueListParameterDisplayOnly">
                        <PropertyValue Property="ValueListProperty" String="BRAND_DESCR"/>
                    </Record>
                </Collection>
            </PropertyValue>
        </Record>
    </Annotation>
</Annotations>

当前该字段的值帮助仅显示可选值列表,无排除选项。我希望添加定义条件的功能,允许排除特定值,请问缺少哪些配置?


要让SmartFilter的值帮助支持排除选项,需要完成以下关键配置:

1. 更新字段的sap:filter-restriction属性

将现有字段注解中的sap:filter-restriction="multi-value"修改为sap:filter-restriction="multi-value, exclude",这个属性直接控制SmartFilter是否启用排除模式。修改后的字段定义如下:

<Property Name="ZBrandId" Type="Edm.String" Nullable="false" MaxLength="60" sap:filter-restriction="multi-value, exclude" sap:label="Marke" sap:creatable="false" sap:updatable="false" sap:sortable="false"/> 

2. 确保值列表实体支持过滤操作

确认值列表对应的实体SH_HZCA_H_BRAND_CDS本身支持OData的过滤语法,这样用户在排除选项中输入筛选条件时,后台能正确返回匹配的候选值。你之前配置的SearchSupported="true"已经为这个功能打下基础,只需保证后端实体支持过滤即可。

完成以上配置后,ZBrandId字段的SmartFilter值帮助会自动显示排除选项,允许用户选择或输入需要排除的品牌ID。


内容的提问来源于stack exchange,提问作者Tudinho

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.10 15:25:15