Skip to Content
avatar image
Former Member

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

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Oct 28, 2015 at 08:13 AM

    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


    Add comment
    10|10000 characters needed characters exceeded