Skip to Content
0

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

Sep 02, 2017 at 09:49 AM

152

avatar image
Former Member

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

    10 |10000 characters needed characters left characters exceeded
    * Please Login or Register to Answer, Follow or Comment.

    2 Answers

    Amrit Kumar Singh Jun 06 at 09:17 AM
    0

    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

    Share
    10 |10000 characters needed characters left characters exceeded
    Srikanth KV Jun 06 at 04:16 PM
    0

    show your view and controller code for the tree

    Share
    10 |10000 characters needed characters left characters exceeded