11-09-2017 10:16 AM
I have a named OData version 4 source in my SAPUI5 application. I need to manipulate object data in a button click event handler like this:
var oContext = evt.getSource().getBindingContext("dsName"); // works
var sPath = oContext.getPath() + "/myPropertyName";
// Approach 1 for setting value to true:
oContext.getModel().setProperty(sPath, true); // not working
// Approach 2:
var item = evt.getSource().getBindingContext("dsName").getObject();
item.myProperty = true; // not working
The only way I managed to change the property value was by two-way-binding it to a control (check input). Can someone tell me if and how it is possible to update OData v4 models in code?