Show TOC

Experimental Two-Way BindingLocate this document in the navigation structure

The two-way binding mode enables the application to update values of a single collection entry without triggering an immediate change request. create and delete operations are not collected and can be called by the application as described above.

Note This feature is experimental and may change in future versions of SAPUI5.

If the two-way binding mode is enabled, the setProperty function of the OData model is called automatically to update the value in the specified entry upon user input. If an update to a property of another entry is performed and there is already an update to an existing entry pending, a rejectChange event is fired and no change to the property value is stored in the model. The application can register to this event. Thus, before updating a different entry, the application has to submit or reset existing changes of the current entry:

  • To reset the current changes the application can call the resetChanges function.
  • To trigger the final update request for the modified entry the application should call the submitChanges function.

Callback handlers for these functions can be handed over as parameters.

To enable the two-way binding for the OData model the default binding mode has to be changed as follows:


After the binding is done, the application should attach to the rejectChange event to handle the user modifications to different entries accordingly and, for example, allow or reject user input for a specific entry.

 	alert("You are already editing another Entry! Please submit or reject your pending changes!");

The application can use the hasPendingChanges function to determine if there is a pending change.

The application can then decide (or let the user decide) when to submit or reject the changes:

var oUpdateBtn = new sap.ui.commons.Button({
 		text : "Update",
 		style : sap.ui.commons.ButtonStyle.Emph,
 		press : function(){
	 				alert("Update successful"););
 					alert("Update failed");});

var oCancelBtn = new sap.ui.commons.Button({
 		text : "Cancel",
 		style : sap.ui.commons.ButtonStyle.Reject,
 		press : function(){

The submitChanges function also has an optional parameter oParameters which currently can have an attribute for an ETag.