Skip to Content
avatar image
Former Member

SAPUI5 Treetable ParentNodeID null

I want to use a treetable with oData Model. I started from this example.

In the example, the parent nodes have ParentNodeID: null, because they have no parent. The subnodes have ParentNodeID: 1 (or 2 or 3 or ...), because they have a parent.

In my data, the parentNodeID for parents is 0 (instead of null). It is coming from the gateway in this way. Even if I keep in my gatewaycode the parentNodeID empty for parents, it is set to 0. I think because it is a number and the default initial value for numbers is 0.

My Treetable isn't working now. I suppose it is looking for a node with ID 0 to use as parent but of course that does not exist.

How can I set the parentNodeID for parent nodes to null (not 0)?

Or should a Treetable also work with parentNodeID for parents is 0? Then the reason why my Treetable is not working will be something else.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Mar 04, 2018 at 06:14 PM


    I will assume that you are using the SAP Gateway service Builder (SEGW) as your OData provider.

    I have 2 questions, the first, is the 'Edm Type' of the field 'ParentNodeID' defined as "Edm.Int32" (in your properties of the entity type of the data model)? And the second, did you check the box 'Nullable' for that same field?

    Do that and don't pass anything to the 'ParentNodeID'.

    Add comment
    10|10000 characters needed characters exceeded

    • Hello Iftah,

      I am facing the same issue and I tried your solution. My 'ParentNodeID' is defined as "Edm.Int32" in SEGW and I have marked it as 'Nullable'. I am passing nothing to the 'ParentNodeID from the backend. But it is still taking 0 as the default value in the frontend because of which the Tree table is not working properly. Can you suggest some other solution?