Skip to Content
avatar image
Former Member

sapui5 how to make odata data to array

i wan to manipulate odata data,so I want to make the odata to array to manipulate.For example i want to check the key data i inseted whether repetition.

i want to make odata data to array,but i don`t binding list or table .i just want to operate it in controller.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Mar 23, 2017 at 10:45 AM
    oModel.read("/EntitySet", { 
    success: function(oData){ //here you can assign the data to your array from the oData parameter } });
    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hello Jingquan,

      you need to define your oData model in your controller and then you can call your service inside that model.

      var sServiceUrl = "/sap/opu/odata/sap/OData_proj_name_SRV"; //OData_proj_name_SRV is your odata srv project name

      var oModel = new sap.ui.model.odata.ODataModel(sServiceUrl, true);

      oModel.read("/EntitySet",{

      sucess:function(oData){

      console.log(oData).

      //here you can see your odata service output in console prompt of you browser. Accordingly you can modify that based //on your requirement.

      }

      });

  • Oct 05, 2017 at 08:30 AM

    Whenever you read from odata, the output you get is in the form of array of objects.

    this._model.read("/yourEntitySet",null,null,false,function(oData){
    			console.log(oData.results); //oData.results is an array		
    	});
    Add comment
    10|10000 characters needed characters exceeded