cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Delete Button without oData

Former Member
0 Kudos

Hi,

we are retreiving Data from our Node.JS Application via AJAX-Calls. We are not using oData because it doesn't fit all our needs. Now we encounter a problem:

In order to delete an Item, we've implemented a Button. On Press it should return an ID, to fire a DELETE call to our API with that ID. I didn't found a solution yet, to hand over an ID from DB into our View, to read that our within the controller.

I already tried to bind that DB-ID to the XML-id-Tag

<Button id="removeTelefon_{modelTelefon>TelefonID}" icon="sap-icon://delete" press="onDeletePhonenumber"/>

but it seems, that those operations are not supported by SAP. So I tried to bind the ID to a hidden Text-Field, because I could receive the clicken Element-Position via oEvent.getSource().getId() (its an incremental Number, i could read out):

<core:InvisibleText id="invisibleText" text="removeTelefon_{modelTelefon>TelefonID}"/>


But nope, no way to get the Invisible Text at the same position as the Button.



TL;DR:

I just want to bind a DB-ID, to a Button, in order to delete an Item via AJAX-Calls for our Node.JS-Backend-Service. oEvent.getSource().getBindingContext().getPath(); wont work, because we aren't using oData.



jQuery-Style:

$('.deleteTelefon').click(function() {

   var id=this.attr('id'); // wont get this with SAPUI5

   // fire ajax call with ID

}

Accepted Solutions (1)

Accepted Solutions (1)

SergioG_TX
Active Contributor
0 Kudos

what if you added it to a custom data attribute ?

check out the documentation

SAPUI5 SDK - Demo Kit

Former Member
0 Kudos

im so glad it works now! thank you!

for all, who are interested in

XML:

<mvc:View

    xmlns:core="sap.ui.core"

    xmlns:l="sap.ui.layout"

    xmlns:mvc="sap.ui.core.mvc"

    xmlns="sap.m" controllerName="..."

    xmlns:app="http://schemas.sap.com/sapui5/extension/sap.ui.core.CustomData/1"

    id="...">
        [......]

        <Button id="remove" app:deleteID="{model>ID}" icon="sap-icon://delete" press="onDelete"/>
       [.....]

</mvc:View>


controller:

onDelete: function(oEvent) {

      console.log(oEvent.getSource().data("deleteID"));

}

Answers (0)