0

我创建了一个带有元数据允许扩展的 CDS 视图,如下所示:

@AbapCatalog.sqlViewName: 'ZAMCCLASSSEL'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Classification selection'
@VDM.viewType: #CONSUMPTION 
@Metadata.allowExtensions: true

define view ZAM_C_CLASS_SEL
  as select from ZAM_I_CLASS_SEL
{
  key InternalClass,
      ClassType,
      ClassNum,
      _ClassKeyword,
      _ClassType
}

复合视图:

@AbapCatalog.sqlViewName: 'ZAMICLASSSEL'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Classification selection'
@VDM.viewType: #COMPOSITE

define view ZAM_I_CLASS_SEL
  as select from ZAM_I_CLASS_HEAD
  association [1..1] to ZAM_I_CLASSTYPE   as _ClassType    on $projection.ClassType = _ClassType.ClassType
  association [1..1] to ZAM_I_CLASS_KEYWS as _ClassKeyword on $projection.InternalClass = _ClassKeyword.InternalClass
{
      @ObjectModel.foreignKey.association: '_ClassKeyword'
  key InternalClass,
      @ObjectModel.foreignKey.association: '_ClassType'
      ClassType,
      ClassNum,
      ValidFrom,
      ValidUntil,
      _ClassType,
      _ClassKeyword
}

和元数据扩展:

@Metadata.layer: #CORE
annotate view ZAM_C_CLASS_SEL with
{

  @UI.hidden: true
  InternalClass;
  @UI.selectionField: [{position: 10}]
  ClassType;
  @UI.selectionField: [{position: 20}]
  ClassNum;

}

smartfilterbar 应该在屏幕上显示两个字段 ClassType 和 ClassNum 作为选择字段:

<mvc:View controllerName="ch.mindustrie.FIORI_ELE_SELECTION.controller.Selection" xmlns:mvc="sap.ui.core.mvc"
    xmlns:smartFilterBar="sap.ui.comp.smartfilterbar" displayBlock="true" xmlns="sap.m">
    <Shell id="shell">
        <App id="app">
            <pages>
                <Page>
                    <smartFilterBar:SmartFilterBar id="smartFilterBar" persistencyKey="UniqueAndStablePersistencyKey" entitySet="ZAM_C_CLASS_SEL"></smartFilterBar:SmartFilterBar>
                </Page>
            </pages>
        </App>
    </Shell>
</mvc:View>  

但相反,我有一个空的 smartfilterbar:

在此处输入图像描述

点击Filters按钮,它显示:

在此处输入图像描述

这意味着,这两个字段都可用,但可能缺少在 smartfilterbar 控件上设置的选项。

更新
我发现,当我改变元扩展如下:

@Metadata.layer: #CORE
annotate view ZAM_C_CLASS_SEL with
{
  @UI.selectionField: [{position: 20}]
  @Consumption.filter : { mandatory: true}
  ClassType;
  @UI.selectionField: [{position: 10}]
  @Consumption.filter : { mandatory: true}
  ClassNum;

}  

将显示选择字段。

4

1 回答 1

0

将 OP 的答案放在这里,以便更好地搜索 SO。

如下更改元扩展时,将显示选择字段:

@Metadata.layer: #CORE
annotate view ZAM_C_CLASS_SEL with
{
  @UI.selectionField: [{position: 20}]
  @Consumption.filter : { mandatory: true}
  ClassType;
  @UI.selectionField: [{position: 10}]
  @Consumption.filter : { mandatory: true}
  ClassNum;

} 
于 2019-10-27T21:00:01.467 回答