0

I got a DB table that contain an attribute that point to its parent node and it also has navigation property "_toSubTasks" and "_toParent". And for this table, there is an OData Service for it.

Example: Task { task_id, parent_task_id, ....}

For each task, we can get its direct sub tasks, but each sub task can also have its own sub tasks. How to get all sub tasks that with all hierarchy level(direct sub tasks and the sub tasks of sub tasks) and display with UI5 tree table?

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Lucifa
  • 23
  • 7
  • You need to build a new hierarchical model based on your initial list.e.g. https://stackoverflow.com/questions/18017869/build-tree-array-from-flat-array-in-javascript – Ji aSH Aug 16 '17 at 07:25
  • Thanks for your answer. Yes, I can build a Json model that contains hierarchy structure and then set model for the tree table. It definitely works. But I believe that the most simple way is use the Navigation property "_toSubTasks" to build hierarchy structure.But I don't know how ... – Lucifa Aug 16 '17 at 10:42

1 Answers1

0

The treetable will evaluate all properties of your main entity. If it finds a property that is an object, or an array, it will consider it as a subnode.

Since your navigation property exists in your odata-model-entity as a deferred object, normally the tree should identify your navigation property as a subnode. (because it's an object)

So I would expect that simply binding your main entity set to the tree-items should be sufficient.

as an additional test, you can try calling the read method of your model, on such a navigation-property. that should execute the deferred and load the related items.

One important remark though: My reasoning above is based on a sap.m.tree element.

FiddleBe
  • 17
  • 3