Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UI5 Tree Table why repeated nodes?

I am trying to bind OData to a Tree Table following the OData Samples in sap.ui.table.TreeTable

I have tried both with basic binding with setting treeAnnotationPropertiesin the xml and annotation binding (I have checked the $metadata query and it has the sap:hierarchy- etc).

However, both times I get repeated nodes like:

Id    | Title     | Hierarchy Level | ParentID 
----------------------------------------------------
1     | izparent  | 0               | 0
|--1  | izparent  | 0               | 0
|  |-- ...
|--2  | izchild   | 1               | 1
2     | izchild   | 1               | 1

where I get a Node with Id 1 which is expandable, and Node 2 which is not expandable. But if I expand Node 1, I again get Node 1 which is expandable and Node 2, and I can repeated expand Node 1 to get the same result.

I have a feeling I have a similar problem as here, but there is no answer provided for this either: How to define tree table annotation (XML view)

I am using OData Version 2.0 and for my et_entity I just provide a SELECT * FROM a table which has the structure I think I need according to the samples.

Table content:

Id | Title    | HierarchyLevel | ParentID | Drillstate
1    izparent   0                0          expanded
2    izchild    1                1          leaf

What could be the issue here?

like image 273
sandboxj Avatar asked Aug 21 '19 08:08

sandboxj


1 Answers

I found that adding operationMode: 'Client' to the rows parameters solved the issue.

It appears that expanding triggers another Server call (additional $batch appears under debugging network tab), and therefore extra logic has to be included in the GetEntitySet method to handle expands on lower hierarchy levels, so it doesn't provide the full hierarchy anymore (e.g. if hierarchy level = ..., then select only hierarchy level < ...). Since the amount of data I am handling allows operationMode: client, I did not further the additional logic approach.

like image 146
sandboxj Avatar answered Nov 15 '22 05:11

sandboxj