cancel
Showing results for 
Search instead for 
Did you mean: 

HANA Model via oData service into sap.ui.table.TreeTable control

msshortza
Explorer
0 Kudos

Hi

Pretty new to UI5 coding so excuse me if terminology is not 100%.

I have a model on HANA exposed as an oData service which I can successfully read into my applet.  Each row from HANA has both the current ID and the PARENT ID, however from what I have read it is currently impossible to natively consume this directly into the TreeTable construct with the correct parent/child relationships.  Is there a way to post-process the oData from HANA to get this into the correct format?

Here is what I have, so far:

      var jasonModel = new sap.ui.model.json.JSONModel();     

      var url = "/odata/PS.xsodata/PPS(P_SAPClient = '100',P_MENID = 'STANDARD')/Results?$select=ID,TLEVEL,ESTCAT,ESTNAM,P_ID,P_TLEVEL,P_ESTCAT,P_ESTNAM&$orderby=ID asc&$format=json";

     

      var oTree = new sap.ui.table.TreeTable({ // create Table UI

          columns : [

              {label: "ID", template: "ID", sortProperty: "ID" }, 

              {label: "TLEVEL", template: "TLEVEL", sortProperty: "TLEVEL" },

              {label: "ESTCAT", template: "ESTCAT", sortProperty: "ESTCAT" },

              {label: "ESTNAM", template: "ESTNAM", sortProperty: "ESTNAM" },

              {label: "P_ID", template: "P_ID", sortProperty: "P_ID" }, 

              {label: "P_TLEVEL", template: "P_TLEVEL", sortProperty: "P_TLEVEL" },

              {label: "P_ESTCAT", template: "P_ESTCAT", sortProperty: "P_ESTCAT" },

              {label: "P_ESTNAM", template: "P_ESTNAM", sortProperty: "P_ESTNAM" } ]

      });     

     

      jasonModel.loadData(url,{},false, "GET"); 

      sap.ui.getCore().setModel(jasonModel);

     

      oTree.setModel(jasonModel);

      oTree.bindRows("/d/results", oTree);

      oTree.placeAt("treeArea");  

So what I need is somehow to loop through the data returned from HANA and put it into the correct parent/child format.

My thanks in advance

Marc

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member182372
Active Contributor
0 Kudos

post json structure from server

msshortza
Explorer
0 Kudos

Here are the first few lines from the server (note I just stripped out the type/uri for readability purposes):

{

  • d:

    {

    • results:
      [
      • {
        • __metadata: {},
          • type: "",
          • uri: ""
        • ID: "000001",
        • TLEVEL: "01",
        • ESTCAT: "SAP_EHS_1000",
        • ESTNAM: "ROOT",
        • P_ID: null,
        • P_TLEVEL: null,
        • P_ESTCAT: null,
        • P_ESTNAM: null
        },

      • {

        • __metadata: {},
          • type: "",
          • uri: ""
        • ID: "100000",
        • TLEVEL: "02",
        • ESTCAT: "SAP_EHS_GENERAL",
        • ESTNAM: "General",
        • P_ID: "000001",
        • P_TLEVEL: "01",
        • P_ESTCAT: "SAP_EHS_1000",
        • P_ESTNAM: "ROOT"
        },

      • {

        • __metadata: {},
          • type: "",
          • uri: ""
          • "
        • ID: "100100",
        • TLEVEL: "03",
        • ESTCAT: "SAP_EHS_1011_001",
        • ESTNAM: "Possible Hazards (Summary)",
        • P_ID: "100000",
        • P_TLEVEL: "02",
        • P_ESTCAT: "SAP_EHS_GENERAL",
        • P_ESTNAM: "General"
        },

      • {

        • __metadata: {},
          • type: "",
          • uri: ""
          • "
        • ID: "100120",
        • TLEVEL: "03",
        • ESTCAT: "SAP_EHS_1011_011",
        • ESTNAM: "Other Hazards (GHS)",
        • P_ID: "100000",
        • P_TLEVEL: "02",
        • P_ESTCAT: "SAP_EHS_GENERAL",
        • P_ESTNAM: "General"
        },

      • {

        • __metadata: {},
          • type: "",
          • uri: ""
          • "
        • ID: "100200",
        • TLEVEL: "03",
        • ESTCAT: "SAP_EHS_1011_002",
        • ESTNAM: "Other Information",
        • P_ID: "100000",
        • P_TLEVEL: "02",
        • P_ESTCAT: "SAP_EHS_GENERAL",
        • P_ESTNAM: "General"
        }

      ]
    }

}