cancel
Showing results for 
Search instead for 
Did you mean: 
Subscribe

I am trying to use Two-Way binding with a v2 OData model. In the route matched of the create view I have the following code.


this.getOwnerComponent().oWhenMetadataIsLoaded.then(function() {

  var oEntry = oView.getModel().createEntry("/ContactCollection");

  oView.setBindingContext(oEntry);

}.bind(this));

  }.bind(this));

At runtime i call the screen and update a value in the create view that is "bound" to the model.

Then in my save function I have been executing the following line in the debugger.


this.getView().getBindingContext().getObject()

The output is a blank entity will all properties set to "undefined".

While searching I found this page

So i implemented line


oView.getModel().setDefaultBindingMode(sap.ui.model.BindingMode.TwoWay);

in the route matched function above with same results.

I have also tried using


oView.unbindElement();

from the discussion here

Any help would be appreciated.

0 Likes
View Entire Topic
junwu
SAP Champion
SAP Champion
0 Likes

how you store the model? with name?

0 Likes

I am using an unnamed model so my binding looks like.


value="{path :'firstName',type: 'sap.ui.model.odata.type.String'}"

junwu
SAP Champion
SAP Champion
0 Likes

when you call

  1. oView.getModel().setDefaultBindingMode(sap.ui.model.BindingMode.TwoWay);  ? before setting binding context?or after?
0 Likes

I did. When I tried it it looked like.


this.getOwnerComponent().oWhenMetadataIsLoaded.then(function() {

  oView.getModel().setDefaultBindingMode(sap.ui.model.BindingMode.TwoWay);

  var oEntry = oView.getModel().createEntry("ContactCollection");

  oView.setBindingContext(oEntry);

});

  }.bind(this));

But still did not work