cancel
Showing results for 
Search instead for 
Did you mean: 

To do calculation on json output from odata and create a new json data

former_member187272
Participant
0 Kudos

Hi experts,

how we can do calculation on json output from odata and create a new json data and feed the json data to ui5 control

thanks in advance

Accepted Solutions (0)

Answers (1)

Answers (1)

karthikarjun
Active Contributor
0 Kudos

Hi Shahid,

By using ODATA Model--->under Success Block--->

var oModel = new sap.ui.model.odata.v2.ODataModel(sServiceUrl, null, username, passwrd,

function(odata){

var data = odata.results;

//Now data has [{ "name":"1" }, {"name" : "2"}]

});

use this data in your JSON Model. if you want to change this structure.

Use for loop to create your own structure.

Check this: Simple OData Binding with SAPUI5 | SCN

OR

You can directly bind odata model to table/list.

for eg:

  1. //navigation service
  2. var sServiceUrl = "/sap/opu/odata/sap/ZT38MP_TM_HIER_SRV/";
  3. var oModel = new sap.ui.model.odata.v2.ODataModel(sServiceUrl, { useBatch : true });
  4.  
  5. oTable.setModel(oModel);
  6.  
  7. //navigation service binding
  8. oTable.bindRows({
  9. path : "/Nodes",
  10. parameters : {
  11. expand : "ChildNodes",
  12. navigation : {
  13. 'Nodes' : 'ChildNodes'
  14. }
  15. }
  16. });


Referred from: http://scn.sap.com/community/developer-center/front-end/blog/2015/10/23/treetable-odata-binding


Thanks,

Karthik A