简体   繁体   中英

Why am I getting oEvent.getParameter('data') undefined on dataReceived event?

this.getView().bindElement({
  path: `/Employees('${this._userId}')`,
  parameters: { expand: 'aaa,bbb,ccc' },
  events: {
    dataReceived: (oEvent) => {
      this.getView().setBusy(false)
      debugger
    }
  }
});

I can see data in the response of the $batch request. When I put a breakpoint in the dataReceived function handler, I can also see the data via this.getView().getModel().getProperty(this.getView().getBindingContext().getPath()) . The parameter oEvent.mParameters.data exists, but the value is undefined .

If I leave out expand , the data is set. Do all entities of an associated entityset need to have an association to its parent?

This is by design according to the API reference of dataReceived :

dataReceived

[...] This event may also be fired when an error occurred .

Param type description
data string The data received; is undefined in error cases

You must have somewhere an error message in the $batch response, or the request was somehow aborted.

The missing data parameter is currently the only documented indicator for a failed request on bindObject / bindElement .


PS: See also https://github.com/SAP/openui5/issues/2263

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM