I have a detail page (Master/Detail), where I get the key of a model as a parameter:
onRoutePatternMatched : function(oEvent) {
var key= oEvent.getParameter("arguments").key;
var oViewModel = this.getView().getModel("model");
var _sProductPath = "model>/ZSDATLOG_MACHMODELSet('" + key+ "')";
this.getView().setBindingContext(oViewModel);
this.getView().bindElement({
path: _sProductPath
});
Now I successfully display the detail data in the view.
Now I want to read the current row of the model in a further function of the controller.
btnPress : function() {
var context = this.getView().getBindingContext();
var object = context.getProperty("/");
With this code I nearly get my elements:
Now that object is in my variable object
.
How should I get the attribute Agr
?
First you should use var context = this.getView().getBindingContext("model");
as you are using a named model.
then you can use something like
var agr = context.getProperty("Agr");
or you can access the member of your object with
var agr = object.Agr;
If you want to access a object member like ZSDATLOG_MACHMODELSet('VBP00099999000117') you can use this syntax:
var agr = object["ZSDATLOG_MACHMODELSet('VBP00099999000117')"].Agr;