I'm reading data from HANA using a JSONModel 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: this.getView().setModel(data);
I have also seen the following way of doing it, where an ODataModel is created and then the JSONModel is created from the data.
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 ODataModel first than creating the JSONModel at once. So assuming I'm getting back from the database about 5,000 data points, which approach should I use, or would there be no difference?
JSONModelis a Client model to get the data and set data to the view for JSON format.ODataModelis a model implementation for OData protocol. This allows CRUD operations on the OData entities.JSONModeldoesn't support Create/Update/Delete/Batch operations.So coming to your scenario, I would suggest to use
ODataModelalways to do CRUD operations (inclusive of read). Then can use JSON model to bind the data to view.Note that it's better to have one
ODataModelper app and multipleJSONModels bound to views.Consider using
ODataModel V2and since you have mentioned that you are dealing with 5K data points, if you don't all the data in the UI. UsesetSizeLimitto make sure you have set proper upper bound.