I have a sap.m.VBox
control, of which the items
aggregation is bound to an ODataModel dataset, and as such is being populated by a sap.m.HBox
template control containing multiple sap.m.Input
controls (which are bound to the respective ODataModel's dataset properties)
In code:
<VBox items="{/My_ODatamodel_Dataset}">
<items>
<HBox>
<Input value="{property1} change="doSomething"/>
<Input value="{property2} change="doSomething"/>
<Input value="{property3} change="doSomething"/>
</HBox>
</items>
</VBox>
(the OData dataset has a filter applied, but I left it out for brevity)
The rendered result will thus be a VBox with multiple rows of HBoxes (one for each entry in my OData set) containing the input fields for these entries.
In my controller, I have the doSomething
method:
doSomething: function(oEvent) {
var oCurrentContext = oEvent.getSource().getBindingContext();
var sSomeHiddenValue = oCurrentContext().getProperty("property4");
// continue to do something special with hidden property 4
}
However, to my surprise oEvent.getSource().getBindingContext()
returns undefined
...
I suppose I'm overlooking something here, but it does work when using a JSON model instead of an OData model...
What I'm trying to achieve, is to get a property value from the current entry in which I'm making a change. Is there a different way of doing so using an OData model?
Any help is highly appreciated!
with the ODataModel you need to get the properties of the context from the Model, try
var oModel = oEvent.getSource().getModel();
var oContext = oEvent.getSource().getBindingContext();
var sSomeHiddenValue = oModel.getProperty("property4", oContext);
hth jsp