The delete operation comes into play whenever an existing entry resource needs to be deleted.The function for deletion is remove.The remove function triggers a DELETE request to an OData service which was specified at creation of the OData model.
In this tutorial we will use our flight service and perform delete operation in flightset.
Pre-requisites
Steps
In this tutorial we will use our flight service and perform delete operation in flightset.
Pre-requisites
- FLIGHTSET_DELETE_ENTITY method implemented in sap backend flight service.
- SAPUI5 Application created.
- OData service (I am using flight service created in earlier tutorials)added to the created application and odata model is set.
Steps
- Our SCARR table before 'delete operation' is like below.We will delete the entry with carrid AI.
- First put below code in our view.Here we will hardcode the flight details in a simple form and place a button below it.On press of the button we will delete the entry through OData.
- Now our view will look like this.
- Add delete logic inside onDelete method of the view's controller.Copy paste below logic.Here we access the key field carrid and pass it to oModel.remove function.
- Run the application and Press update button.You will get a success alert if deletion was successful.Go to sap backend and check the table SCARR.Now you can see the carrier details of AI carrier is deleted.
<mvc:View controllerName="odataaaa.controller.View1" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:f="sap.ui.layout.form" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m"> <App> <pages> <Page title="{i18n>title}"> <content> <f:SimpleForm id="simpleFormChange" title="Carrier Details" editable="true" class="editableForm sapUiSmallMarginTopBottom"> <f:content> <Label text="Carrier id"/> <Input id="carrid" value="AI"/> <Label text="Carrier name"/> <Input id="carrname" value="Air India"/> <Label text="Currency code"/> <Input id="currcode" value="INR"/> <Label text="Carrier Url"/> <Input id="url" value="http://airindia.com"/> </f:content> </f:SimpleForm> <Button text="delete" press="onDelete"></Button> </content> </Page> </pages> </App> </mvc:View>
onDelete: function() { /*delete operation*/ var oModel = this.getView().getModel(); var Carrid = this.getView().byId("carrid").getValue(); oModel.remove("/FlightSet('"+Carrid+"')", { method: "DELETE", success: function(data) { alert("success"); }, error: function(e) { alert("error"); } }); }
If you enjoyed this post, Please Share!!
Hi Rajeesh,
ReplyDeletethanks for the example. How can I achive the following behaviour using your oModel bound to OData v2: the oModel.remove method should be called but the DELETE request to backend server should not be sent automatically. Instead, the row should be deleted in the client and later on posted to backend if oModel.submitChanges is executed in a button press event handler for instance? Is this possible?
Yours
Stephan
Hi Stephan ,
DeleteI think you are talking about batch operation. This tutorial may help you Batch operation SAPUI5
40BA113B6F
ReplyDeletecialis
themra macun
bufalo içecek
performans arttırıcı
degra
vigrande
viga
novagra
yapay kızlık zarı
CD883EEE70
ReplyDeletebufalo çikolata
cam şov
maxman
themra macun
sildegra
kamagra
viagra
performans arttırıcı
cobra vega
2AE8834945
ReplyDeletefx15
canli web cam show
görüntülü show
yapay kızlık zarı
viagra
maxman
geciktirici
vega
vigrande
346EB16482
ReplyDeletewhatsapp kameralı show
CA0E94E392
ReplyDeletevega
cam şov
kamagra hap
cam show
viagra
stag
cobra vega
whatsapp görüntülü show güvenilir
whatsapp görüntülü şov
84445E8F26
ReplyDeletetwitter türk beğeni
ED6AD03ECA
ReplyDeleteşov
cialis
steroid satın al