Skip to Content
avatar image
Former Member

Sap.m.tree with Odata example, and how to build Odata service for Tree to show org structure

Hi All,

I need help to understand how a real OData can be used for sap.m.tree, I been through some examples with JSON model

https://sapui5.hana.ondemand.com/#/entity/sap.m.Tree

 [
{
"text": "Node1",
"ref": "sap-icon://attachment-audio",
"nodes":
[
{
"text": "Node1-1",
"ref": "sap-icon://attachment-e-pub",
"nodes":[
{
"text": "Node1-1-1",
"ref": "sap-icon://attachment-html"
},
{
"text": "Node1-1-2",
"ref": "sap-icon://attachment-photo",
"nodes":[
{
"text": "Node1-1-1",
"ref": "sap-icon://attachment-text-file",
"nodes":[
{
"text": "Node1-1-1-1",
"ref": "sap-icon://attachment-video"
},
{
"text": "Node1-1-1-2",
"ref": "sap-icon://attachment-zip-file"
},
{
"text": "Node1-1-1-3",
"ref": "sap-icon://course-program"
}
]
}
]
}
]
},
{
"text": "Node1-2",
"ref": "sap-icon://create"
}
]
},
{
"text": "Node2",
"ref": "sap-icon://customer-financial-fact-sheet"
}
]

struggling to understand how it works with OData if I would like to build OData based on above JSON structure I need help to build an entity (not sure what is nodes).

    1. <EntityTypeName="OrgUnit"sap:content-version="1">
      1. <Key>…</Key>
      2. <PropertyName="OuName"Type="Edm.String"Nullable="false"MaxLength="40"sap:unicode="false"sap:label="Name"sap:creatable="false"sap:updatable="false"sap:sortable="false"sap:filterable="false"/>
      3. <PropertyName="OuId"Type="Edm.String"Nullable="false"MaxLength="8"sap:unicode="false"sap:label="Object ID"sap:creatable="false"sap:updatable="false"sap:sortable="false"sap:filterable="false"/>
      4. <PropertyName="ImageUri"Type="Edm.String"Nullable="false"MaxLength="255"sap:unicode="false"sap:label="URL"sap:creatable="false"sap:updatable="false"sap:sortable="false"sap:filterable="false"/>
      5. <PropertyName="ImageIsIcon"Type="Edm.Boolean"Nullable="false"sap:unicode="false"sap:label="Indicator"sap:creatable="false"sap:updatable="false"sap:sortable="false"sap:filterable="false"/>
      6. </EntityType>

    I build my Odata Entity in above manner, used "ImageIsIcon" for nodes filed of JSON in above example and the data type of ImageIsIcon is boolen. when I ran application I am getting below error

    Uncaught TypeError: t.getExpandFirstLevel is not a function

    Thanks

    Rajesh

    Add comment
    10|10000 characters needed characters exceeded

    • Get RSS Feed

    3 Answers

    • Jun 06 at 09:17 AM

      Hi,

      I was looking for a similar requirement, did you find a way to achieve it. If yes, Please help me with this.

      Regards,

      Amrit

      Add comment
      10|10000 characters needed characters exceeded

    • Jun 06 at 04:16 PM

      show your view and controller code for the tree

      Add comment
      10|10000 characters needed characters exceeded

    • 3 days ago

      Use OdataModel version 2 i.e. "sap/ui/model/odata/v2/ODataModel"

      I know its too late but its for the help of others as I faced the same issue recently.

      Add comment
      10|10000 characters needed characters exceeded