0
votes

I have an odata service that has query and a read. Once an Item is selected from the query I want to bind a property of the entity (that is only obtained through the read) to a property of an element on in the view. I have the view changing with the path to the entity being passed through the EventBus and I can see that the property of the entity is bound correctly with the SAPUI5 debugger. I can also see that after binding the entity property is blank. I have checked the calls in the chrome debugger and no calls where made for the read request. I can call the read request successfully in the browser.

Here is my function for binding:

loader: function(oEvent, oName, oParams) {
        var oView = this.getView();
        var oText = oView.byId('__area0');
        var sEntityPath = '/' + oParams.entity;
        var oModel = oView.getModel();
        var oContext = new sap.ui.model.Context(oModel, sEntityPath);

        oView.setBindingContext(oContext);
        oText.bindProperty('value','Contents');
    }

"Contents" is the name of the property oText is a TextArea

Thanks for your help!

2

2 Answers

0
votes

Shortly after typing out my question I read the "Similar Questions" on the side and found this link that was able to help me out. I figured I would go ahead and post it in case there where others like me

0
votes

You can bind an entity to the view using bindElement method,

var oView = this.getView();
var oText = oView.byId('__area0');
var sEntityPath = '/' + oParams.entity;
oView.bindElement(sEntityPath);
oText.bindProperty('value','Contents');