Homelab, Linux, JS & ABAP (~˘▾˘)~
 

[SAPUI5] Model binding events

1
2
3
4
5
6
7
8
this.getView().bindElement({
                path: sObjectPath,
                events: {
                    dataRequested: (oEvent) => {}, // Executed when a request to server is send
                    dataReceived: (oEvent) => {},  // Executed when data from server is received
                    change:(oEvent) => {},         // Executed everytime you do ElementBinding
                }
            })

The events for dataRequested and dataReceived are only fired, when data is requested or data is received from a backend. This is not the case, when the requested data is already available in the model from a previous backend call. In such situations, the change event comes in handy.

The same can also be done via XML:

1
2
3
4
5
6
7
8
binding="{
  path: '/myEntitySet',
  events: {
    dataRequested: 'onDataRequested',
    dataReceived: 'onDataReceived',
    change: 'onDataChange'
  }
}"