我创建了具有元数据允许扩展的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;
}
将显示选择字段。
答案 0 :(得分: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;
}