Skip to Content
0

sapui5 how to make odata data to array

Mar 23, 2017 at 08:45 AM

242

avatar image
Former Member

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.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

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

could you give me the example? i am newer and i don`t how to write the code

0
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.

}

});

0
Arjun Biswas Oct 05, 2017 at 08:30 AM
0

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		
	});
Share
10 |10000 characters needed characters left characters exceeded