Reputation: 1238
I have a problem with a getBinding
using UI5.
I can bind a List to a JSON Model like so.
var sServiceUrl = "http://localhost:56154/api/store";
var myModel = new sap.ui.model.json.JSONModel();
myModel.loadData(sServiceUrl);
oView.setModel(myModel);
Alternatively, I can specify a 'name' for the model by changing the last line as follows:
oView.setModel(myModel, "foo");
Both work fine! I reference them (in my XML views) as below (items attribute refers).
Without a named reference to the mode:
<List items="{/}">
With a named reference to the mode:
<List items="{foo>/}">
Problem Statement
This command fails when I attempt to retrieve the binding context (in the case of the named model. the exact issue is getBindingContext() is undefined).
var sPath = oEvent.getParameter("listItem").getBindingContext();
Can anyone help me understand what to do - I presume the '>' in may cause the problem but given naming a model is standard/good practice. I am not sure why this should cause the function to fail.
Upvotes: 1
Views: 689
Reputation: 4232
You have to pass the model name to the method:
oEvent.getParameter("listItem").getBindingContext("foo")
Upvotes: 3