Skip to content

Commit 4ddf2bf

Browse files
committed
Simplified Fiori Tree View
1 parent 8e3d001 commit 4ddf2bf

File tree

1 file changed

+47
-29
lines changed

1 file changed

+47
-29
lines changed

advanced/fiori.md

Lines changed: 47 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -745,9 +745,9 @@ Cache Control feature is currently supported on the Java runtime only.
745745

746746
## Hierarchical Tree Views
747747

748-
Recursive hierarchies are parent-child hierarchies, where each entity references its parent and through that defines the hierarchical structure. A common example is a company organization structure or HR reporting, where each employee entity references another employee as a direct report or manager.
748+
Recursive hierarchies are parent-child hierarchies: each entity references its parent and through that defines the hierarchical structure. A common example is a company organization structure or HR reporting, where each employee entity references another employee as a direct report or manager.
749749

750-
A generic hierarchy implementation for hierarchies is available on all relational datases supported by the CAP runtimes.
750+
A generic hierarchy implementation for hierarchies is available on all relational databases supported by the CAP runtimes.
751751

752752
::: warning
753753
On H2, only small hierarchies should be used for performance reasons.
@@ -761,6 +761,7 @@ Let's assume we have the following domain model and its projection in a service:
761761
namespace my.bookshop;
762762
763763
entity Genres { //...
764+
ID : UUID;
764765
parent : Association to Genres;
765766
}
766767
```
@@ -774,8 +775,51 @@ service AdminService {
774775
```
775776
:::
776777

778+
In this example, there is a managed to-one association `parent` that defines the parent-child hierarchy
779+
based on a single key element. In such a situation you can define the Tree View via the annotation `@hierarchy`:
777780

778-
Annotate/extend the entity in the service as follows:
781+
```cds
782+
annotate AdminService.Genres with @hierarchy : parent;
783+
```
784+
785+
If the entity contains only one such association, you can even omit the value:
786+
787+
```cds
788+
annotate AdminService.Genres with @hierarchy;
789+
```
790+
791+
Configure the TreeTable in UI5's _manifest.json_ file:
792+
793+
```jsonc
794+
"sap.ui5": { ...
795+
"routing": { ...
796+
"targets": { ...
797+
"GenresList": { ...
798+
"options": {
799+
"settings": { ...
800+
"controlConfiguration": {
801+
"@com.sap.vocabularies.UI.v1.LineItem": {
802+
"tableSettings": {
803+
"hierarchyQualifier": "GenresHierarchy", // [!code focus]
804+
"type": "TreeTable" // [!code focus]
805+
}
806+
}
807+
}
808+
}
809+
}
810+
},
811+
},
812+
},
813+
```
814+
815+
> Note: construct the `hierarchyQualifier` with the following pattern: <br>
816+
> `<entity name in service>Hierarchy`
817+
818+
![Fiori UI with hierarchical trree view.](assets/hierarchical-tree-view.png) {style="filter: drop-shadow(0 2px 5px rgba(0,0,0,.40));"}
819+
820+
The compiler automatically expands the shortcut annotation `@hierarchy` to the
821+
following annotate and extend statements. If you cannot use the `@hierarchy` annotation,
822+
e.g. because you only have an unmanaged parent association, you can write them yourself.
779823
780824
```cds
781825
// declare a hierarchy with the qualifier "GenresHierarchy"
@@ -811,31 +855,5 @@ extend AdminService.Genres with @(
811855
> Note: When naming the hierarchy qualifier, use the following pattern: <br>
812856
> `<entity name in service>Hierarchy`
813857
814-
Configure the TreeTable in UI5's _manifest.json_ file:
815-
816-
```jsonc
817-
"sap.ui5": { ...
818-
"routing": { ...
819-
"targets": { ...
820-
"GenresList": { ...
821-
"options": {
822-
"settings": { ...
823-
"controlConfiguration": {
824-
"@com.sap.vocabularies.UI.v1.LineItem": {
825-
"tableSettings": {
826-
"hierarchyQualifier": "GenresHierarchy", // [!code focus]
827-
"type": "TreeTable" // [!code focus]
828-
}
829-
}
830-
}
831-
}
832-
}
833-
},
834-
},
835-
},
836-
```
837-
838-
> Note: use the `hierarchyQualifier` declared earlier
839-
840858
<div id="reserved-words" />
841859

0 commit comments

Comments
 (0)