cancel
Showing results for 
Search instead for 
Did you mean: 

"oModel.oData" warning

0 Kudos

I am fixing the warnings of some code. There is a warning in the code below:

onDeleteListItem: function(oEvent) {
			this.getView().byId("tileList");
			var sPath = oEvent.getParameters("list").listItem.getBindingContext().sPath;
			var iLength = sPath.length;
			var iIndex = sPath.slice(iLength - 1);
			var oModel = this.getView().getModel();
			var oData = oModel.oData;
			oData.TileCollection.splice(iIndex, 1);
			oModel.setData(oData);
		}

In this line

var oData = oModel.oData;

there is a warning: Property oData is a private member of sap.ui.model.odata.v2.ODataModel. (sap-no-ui5-prop-warning).

How can I fix it?

Thank you!

Accepted Solutions (1)

Accepted Solutions (1)

maheshpalavalli
Active Contributor
0 Kudos

Hi Jerry,

You are directly accessing oData property which is private property..

Assuming that this is a JSON model, you need to use oModel.getData() (similar to oModel.setData), which will return you the data

You can check the API reference for more details

BR

Mahesh

Answers (1)

Answers (1)

boghyon
Product and Topic Expert
Product and Topic Expert
0 Kudos

In case of OData for other readers, this might help: https://stackoverflow.com/a/54554635/

Generally, UI5 provides almost always an appropriate API for every common case for which the API reference should be checked.

Accessing non-public fields as an application developer is considered highly risky and harmful for upward compatibility.