You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: advanced/fiori.md
+55-32Lines changed: 55 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -745,9 +745,9 @@ Cache Control feature is currently supported on the Java runtime only.
745
745
746
746
## Hierarchical Tree Views
747
747
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 related structures: 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.
749
749
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.
751
751
752
752
::: warning
753
753
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:
761
761
namespace my.bookshop;
762
762
763
763
entity Genres { //...
764
+
ID : UUID;
764
765
parent : Association to Genres;
765
766
}
766
767
```
@@ -774,19 +775,67 @@ service AdminService {
774
775
```
775
776
:::
776
777
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`:
777
780
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:
> Note: construct the `hierarchyQualifier` with the following pattern: <br>
816
+
> `<entity name in service>Hierarchy`
817
+
818
+
You can now start the server with `cds watch` and see the hierarchical tree view in action in the [_Browse Genres_](http://localhost:4004/fiori-apps.html#Genres-display) app.
819
+
820
+
 {style="filter: drop-shadow(0 2px 5px rgba(0,0,0,.40));"}
821
+
822
+
The compiler automatically expands the shortcut annotation `@hierarchy` to the
823
+
following `annotate` and `extend` statements.
824
+
825
+
### Manual Approach
826
+
827
+
The following documents what happens behind the scenes, done by the compiler as described before. You can also use it, if you cannot use the `@hierarchy` annotation, for example, because you only have an unmanaged parent association.
779
828
780
829
```cds
781
830
// declare a hierarchy with the qualifier "GenresHierarchy"
782
-
annotate AdminService.Genres with @Aggregation.RecursiveHierarchy #GenresHierarchy: {
0 commit comments