如何将“定义条件”部分添加到 UI5 SmartFilter 中的值帮助?

问题描述 投票:0回答:1

应用程序UI5版本:1.44

我增强了标准 oData 服务,并向其中一个实体添加了自定义字段。然后我创建了一个注释,以启用此自定义字段的值帮助以在 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>

当我执行此自定义字段的值帮助时,我会看到一个搜索对话框,其中显示了可供选择的值列表。看起来像这样:

ValueList without exclude option

但是,我希望还可以选择能够定义条件,即排除值,类似于此:

ValueList with exclude option

知道我错过了什么吗?

odata sapui5
1个回答
0
投票

如果字段允许过滤多个值,则条件选项卡会自动出现。 为过滤器选择类型编写注释:MultileValue 示例代码:

data : lo_annotation  type ref to /iwbep/if_mgw_odata_annotation,
   lo_property    type ref to /iwbep/if_mgw_odata_property,
   lo_entity_set  type ref to /iwbep/if_mgw_odata_entity_set,
   lo_entity_type type ref to /iwbep/if_mgw_odata_entity_typ.
try .
    "make plant mandatory and single value
    lo_entity_type = model->get_entity_type( iv_entity_name = gc_pidocument ).
    lo_property = lo_entity_type->get_property( iv_property_name = 'Plant' ).

lo_annotation->add( iv_key   = 'filter-restriction'
                    iv_value = 'multile-value' ).



 catch /iwbep/cx_mgw_med_exception  .
endtry.
© www.soinside.com 2019 - 2024. All rights reserved.