带有 TreeTable 的 Fiori 元素列表报告中不使用注释

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

我创建了一个 Fiori Elements List Report 并将表格类型设置为 TreeTable。该表显示为 TreeTable,但每个实体都显示为表中的根实体,并且日志中出现以下错误:“既没有向 TreeBinding 提供导航路径参数,也没有(完整/有效)树层次结构注释。 ”。

OData 服务基于以下投影视图:

@Metadata.allowExtensions: true
@ObjectModel.representativeKey: 'Element'

@ObjectModel.dataCategory: #HIERARCHY
@Hierarchy.parentChild: [
    { recurse.child: ['Element'],
      recurse.parent: ['ParentElement'],
      recurseBy: '_ParentElement',
      multipleParents: true,
      siblingsOrder: [{by: 'Element', direction: #DESC}],
      orphanedNode.handling: #ROOT_NODES
    }
 ]

define root view entity ZC_Element
  as projection on ZI_Element
{
      @ObjectModel.foreignKey.association: '_Element'
  key Element,
      ParentElement,
      ChildNode,
      ParentNode,
      HierarchyLevel,
      HierarchyTreeSize,
      HierarchyRank,
      HierarchyParentRank,
      HierarchyIsOrphan,
      HierarchyIsCycle,     
      HierarchyDrillState,
      CreatedBy,
      CreatedAt,
      LastChangedBy,
      LastChangedAt,
      _Element,
      _ParentElement
}

作为视图基础的层次结构如下:

define hierarchy ZHI_ElementHierarchy
  as parent child hierarchy(
    source ZHI_ElementRelation
    child to parent association _ParentElement
    start where
      ParentElement is initial
    siblings order by
      Element
    multiple parents allowed
    orphans root
  )
{
      @ObjectModel.foreignKey.association: '_VirtualDirectory'
  key Element,
      _Element,
      ParentElement,
      _ParentElement,
      $node.parent_id             as ParentNode,
      $node.node_id               as ChildNode,
      $node.hierarchy_is_orphan   as HierarchyIsOrphan,
      $node.hierarchy_level       as HierarchyLevel,
      $node.hierarchy_rank        as HierarchyRank,
      $node.hierarchy_parent_rank as HierarchyParentRank,
      $node.hierarchy_tree_size   as HierarchyTreeSize,
      $node.hierarchy_is_cycle    as HierarchyIsCycle,
      CreatedBy,
      CreatedAt,
      LastChangedBy,
      LastChangedAt
}

OData服务的元数据文件不包含任何层次结构注释。我还尝试将以下注释手动添加到annotations.xml 文件中,但这也没有任何效果:

<Annotations Target="cds_zsd_elements.ElementType">
    <Annotation Term="UI.LineItem">
        <Collection>
            <Record Type="UI.DataField">
                <PropertyValue Property="Value" Path="Element"/>
                <PropertyValue Property="sap:hierarchy-node-for" Path="Element"/>
            </Record>

            <Record Type="UI.DataField">
                <PropertyValue Property="Value" Path="ParentElement"/>
                <PropertyValue Property="sap:hierarchy-parent-node-for" Path="Element"/>
            </Record>

            <Record Type="UI.DataField">
                <PropertyValue Property="Value" Path="HierarchyLevel"/>
                <PropertyValue Property="sap:hierarchy-level-for" Path="Element"/>
            </Record>     

            <Record Type="UI.DataField">
                <PropertyValue Property="Value" Path="HierarchyDrillState"/>
                <PropertyValue Property="sap:hierarchy-drill-state-for" Path="Element"/>
            </Record>                    
        </Collection>
    </Annotation>
</Annotations>

我也在 ABAP 程序中使用了 ALV TreeTable 的投影视图,并且输出显示正确,因此层次结构和数据似乎是正确的。我该怎么做才能使层次结构注释正确?

sapui5 sap-fiori cds
1个回答
0
投票

有人知道如何进行这项工作吗?我面临着同样的问题。 😞

谢谢!

© www.soinside.com 2019 - 2024. All rights reserved.