cancel
Showing results for 
Search instead for 
Did you mean: 

SAP CAP and SAPUI5 Hierarchy for Tree Table, how to implement hierarchy-node-descendant-count?

florin1335
Explorer
0 Kudos

Hi,

I'm trying to implement a SAPUI5 smart tree table with oData v2, using a CAP backend application. I added the following SAP annotations, as found in another guide: @Sap.hierarchy.node.for, @Sap.hierarchy.level.for, @Sap.hierarchy.parent.node.for, @Sap.hierarchy.drill.state.for, and the hierarchy is shown properly in the table.

The thing is, there will be a request for each expandable node which is not ideal for performance and it also makes the table lose it's state after a refresh/rebind. This wouldn't be great for me as I want to provide some crud operations on the items and I'd have to refresh the data after saving, which would reset the scroll and node expand status.

I'm wondering if I'd be able to implement the hierarchy-node-descendant-count annotation in CAP as mentioned in the documentation for https://sapui5.hana.ondemand.com/#/api/sap.ui.model.odata.v2.ODataModel%23methods/bindTree : Services which include the hierarchy-node-descendant-count-for annotation and expose the data points sorted in a depth-first, pre-order manner, can use an optimized auto-expand feature by specifying the numberOfExpandedLevels in the binding parameters. This will pre-expand the hierarchy to the given number of levels, with only a single initial OData request. I also saw some hints about a 'Tree state restoration' in the source code for ODataTreeBinding if that annotation is implemented together with hierarchy-sibling-rank-for and hierarchy-preorder-rank-for.

 

Later edit: I was able to add the aforementioned fields and annotations for descendant count, preorder and sibling rank, but filters and sorting aren't working properly anymore as they are breaking the tree structure.

Accepted Solutions (0)

Answers (0)