on 02-18-2019 6:34 PM
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!
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.