Reputation: 91
I'm trying to implement odata v4 for my current master detail app which was using odata v2.
In my app, I used some statements like these.
this.getOwnerComponent().getModel().metadataLoaded().then(fnSetAppNotBusy);
var oContext = this.getModel().createEntry(sPath, {
properties: {
Name: "ABC",
Age: "20"
},
success: this._fnEntityCreated.bind(this),
error: this._fnEntityCreationFailed.bind(this)
});
I see in this document Changes Compared to OData V2 Model, odata v4 has replaced metadataLoaded with "corresponding methods".
I have searched and found some but am not sure if these methods are correct. Can someone please confirm?
And I can't find method createEntry in oDataModel v4, so how can I implement the same logic as I did with odata v2?
Thanks
Upvotes: 1
Views: 1009
Reputation: 2206
Hmm. The creation is covered in this example:
https://sapui5.hana.ondemand.com/sdk/#/sample/sap.ui.core.tutorial.odatav4.06/code
(Basically, you execute the creation on binding/context level)
As for onMetadataLoaded
, you may use getMetaModel()
and then use the „appropriate” functions with promises, but I’d go as follows: grab your binding, which is the one you are waiting for, and attach to the event dataReceived
. E.g.,
oTable.getBinding('items').attachEvent('dataReceived', function(){...})
The API docs explicitly states that this event is to be used for busy indicators:
Upvotes: 1