Adam Harkus
Adam Harkus

Reputation: 2210

Can you expand a sap.m.Tree via a navigation property?

I've set up a sap.m.Tree bound to a "Blocks" entity set of a v2 OData service.

This pulls in all of the entities fine.

However, the "Blocks" entity has a navigation property named "ChildBlocks", which I want to show when expanding the tree.

How can this be done with sap.m.Tree?

I've tried the below code, to no avail.

<Tree xmlns="sap.m"
  id="nodes"
  items="{
    path: '/Blocks',
    templateShareable: false,
    properties: {
      navigation: {
        ChildBlock: '/ChildBlocks'
      }
  }"
><!-- ... --></Tree>

I get the below error:

Neither navigation paths parameters, nor (complete/valid) tree hierarchy annotations where provided to the TreeBinding.

Upvotes: 1

Views: 512

Answers (1)

Boghyon Hoffmann
Boghyon Hoffmann

Reputation: 18044

Expanding tree via navigation property is technically possible but it's deprecated. According to the API reference v2.ODataModel#bindTree parameter navigation:

Deprecated: since 1.44 The use of navigation properties to build up the hierarchy structure is deprecated. It is recommended to use the hierarchy annotations [...] instead.

Samples based on hierarchy annotations:

Upvotes: 1

Related Questions