on 06-28-2016 12:48 PM
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
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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"));
}
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.