Skip to Content
0
Jun 11, 2015 at 10:41 AM

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

33 Views

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