I have created an ODATA Call to the Northwind database, I have been playing with bindings and have some questions that I could not figure out.
In this specific example when I click Login it is going to display the value in the text box, and also open a messagebox to display the same, but the very first time i click it won't display anything. After the second time it works. Why is this happening?
Another question is if I can change the bind of the textbox dynamically instead of using {CompanyName} I would like to get the ContactName but when I use SETVALUE it will print the text {ContactName}. Thanks again!
https://jsbin.com/nofunecane/1/edit?html,output
sap.m.MessageBox.alert(this.getView().getModel().getProperty("/Customers('ALFKI')/CompanyName"));
This is the new code with the Success Method: https://jsbin.com/gagajusoja/edit?html,output
I didn't quite get what was your intention, because what you are doing in the "getLogin" function is:
In order to do so, use the dataReceived callback when bindElement . So your function will look like this:
getLogin: function(evt) {
var oModel = this.getView().getModel();
this.byId("txtUid").bindElement({
path: "/Customers('ALFKI')",
events: {
dataReceived: function(oResponse) {
sap.m.MessageBox.alert(oModel.getProperty("/Customers('ALFKI')/CompanyName"));
}
}
});
this.getView().getModel().read("/Customers('ANATR')", {
success: function(oResponse) {
sap.m.MessageBox.alert(oModel.getProperty("/Customers('ANATR')/CompanyName"));
}
});
}
As for your 2nd question, you can use bindProperty method programmatically.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.