Skip to Content
0

what benefits do I get from using oData model vs Json model

Dec 20, 2016 at 10:06 PM

525

avatar image

I'm reading data from HANA using a JSON model and simply passing in the URL to the source and retrieving it as in the following:

var data = new sap.ui.model.json.JSONModel(urlPath);

Then I can bind it to my view.

I have also seen the following way of doing it, where an oData model is created and then the JSON model is created from the oData.

var oModel = new sap.ui.model.odata.ODataModel(urlPath);       
oModelJson = new sap.ui.model.json.JSONModel();
oModel.read("/Items", null, ["$filter=ImItems eq 'imputParameter'"], null, function(oData, oResponse){ 
   oModelJson.setData(oData);
}, null );
 

What difference is there in creating the oData model first than creating the json model at once. So assuming I'm getting back from the database about 5,000 data points, which approach should I use, or is there be no difference?

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

2 Answers

Jun Wu Dec 21, 2016 at 04:22 AM
0

it will be more easier to use odata model to communicate with odata service.

odata query can be very complex, you are using simple one, that's why you didn't see the difference.

Share
10 |10000 characters needed characters left characters exceeded
Sergio Guerrero Dec 22, 2016 at 08:25 PM
0

the main difference between the 2 model types is that :

oData models are server side -

JSON models are client side -

you can manipulate the json model easier from the client side .. whereas the odata model would have to be interacted with and updated from the server side which involves network interaction. you could do the interaction with the client side model and not having to submit anything until you are ready for it

Share
10 |10000 characters needed characters left characters exceeded