Skip to Content

deletion of single row in sap ui5

hi experts,

i have created rows dynamically and each row contains a delete button, if i click on that delete button the row should be deleted

please help me

my view.xml

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

xmlns="sap.m" controllerName="z_adding_rows.Main" xmlns:html="">

<Page title="Title">


<Table id="idProductsTable" mode="SingleSelectMaster"

selectionChange="onSelectionChange" items="{/}">


<Column width="45%">

<Label text="First Name" />


<Column width="45%">

<Label text="Last Name" />


<Column width="10%">

<Label />






<Input value="{FirstName}" />

<Input value="{LastName}" />

<Button text="Delete" press="onDelete"/>





<Button text="Add Row" press="onPress" />




my controller.js

sap.ui.controller("z_adding_rows.Main", {

onInit: function(oEvent) {

var dataObject = [{

FirstName: "Madhu",

LastName: "Sudhan"


var oModel = new sap.ui.model.json.JSONModel();




onPress: function(oEvent){

var oTable = this.getView().byId("idProductsTable");

var oModel = oTable.getModel().getProperty("/");

var nObject = {FirstName:"", LastName:""};


oTable.getModel().setProperty("/", oModel);


onSelectionChange: function(oEvent) {

var oSelectedItem = oEvent.getParameter("listItem");

var oModel = oSelectedItem.getBindingContext().getObject();



onDelete : function(){

"Are you sure you want to delete this item", {

icon: sap.m.MessageBox.Icon.WARNING,

title: "Delete item",

actions: [sap.m.MessageBox.Action.YES, sap.m.MessageBox.Action.NO],

onClose: function(oAction) {









Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Jun 22, 2016 at 08:02 AM

    Hi Madhu,

    Will this sample help? JS Bin - Collaborative JavaScript Debugging


    Sai Vellanki.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 22, 2016 at 07:54 AM
    onDelete: function(oEvent) { var oModel = this.getView().getModel(); var sPath = oEvent.getSource().getBindingContext().sPath;

    oModel.remove(sPath, { success: function() {"Delete item"); }, error: function() {"Item deletion failed"); } }); }
    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.