我创建了一个带有元数据允许扩展的 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;
}
将显示选择字段。