Skip to Content
author's profile photo Former Member
Former Member

Bind button in row to the table row

I have an Edit and Delete button in each row of an oData table. I wanted to know how to bind each button to its respective row, so when I click a particular button, I can edit and save a particular row.

Here's what my table looks like.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Jan 26, 2014 at 04:37 AM

    Hi Saneth,

    On click on buttons, change the model and set the model to table inside press function.

    It will reflect in table immediately.

    And if you tell which type of operations you want to do, we can help better..

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 25, 2014 at 08:09 PM

    Hi Saneth,

    current binding context could be used to edit and delete row

    below example might help

    Thanks and Regards, Venkatesh

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Venkatesh,

      Thank you for the example. I tried this method, and it works. However, once initally loading the table, it starts of as an editable table. After using the Edit Save button once, it begins to work the way it should.

      Any idea why this is happening?

      Here's the code.

      oTable = new sap.ui.table.DataTable({
        id: "productTable",
          title: "Carbon Footprint Data",
          selectionMode : sap.ui.table.SelectionMode.Single,
        visibleRowCount: 20,
        editable : false,                                   
      oTable.addColumn(new sap.ui.table.Column({
          label: new sap.ui.commons.Label({text:"Edit"}),
          template: new  sap.ui.commons.Button({text:"Edit", press: function(){
          var currentContext = this.getBindingContext();
                   var oCurrentModel = currentContext.getModel();
                   selectedProductID = oCurrentModel.getProperty("ID", currentContext);
          width: "120px"

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.