Skip to Content

unable to enable button on row selection

Hello Team,

I am trying to enable "Edit button" by selection of a Table row, but it is not getting highlighted.error.jpg

Thanks & Regards,
Subrata Roy

error.jpg (86.1 kB)
Add a comment
10|10000 characters needed characters exceeded

Related questions

5 Answers

  • Posted on Jun 20, 2020 at 01:22 PM
    that.getView().byId("test") this will give you template, it is not the actual button in the cell. each cell is a copy  of that template.
    
    better to use data binding to enable or disable the button.
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 21, 2020 at 12:36 AM

    Do it through a model property:

    <Button id="EditButtonID" enabled="{yourLocalModel>/IsRowEditable}" >

    You will probably want the Edit Button to be enabled only if ONE SINGLE row is selected, therefore, use the table's "rowSelectionChange" event, and the code would be like this:

     onRowSelectionChange: function (oEvent) {
     var oTable = oEvent.getSource();
     var bIsRowEditable = !!(oTable.getSelectedIndices().length === 1);
     this.getModel("yourLocalModel").setProperty("/IsRowEditable", bIsRowEditable);
     },
    
    Add a comment
    10|10000 characters needed characters exceeded

    • Hello Artyom,

      Thanks for your input.

      I have tried the above functionality but it is not working.

      Can you please guide me on this or provide me a sample application so that i can refer to.

      ::::Worklist.contrller.js(syntax):::
      onInit: function () {
                      var oViewModel,
                          iOriginalBusyDelay,
                          oTable = this.byId("table");
                         oTable.attachSelectionChange(this.onRowSelectionChange, this);
      onRowSelectionChange: function (oEvent) { var oTable = oEvent.getSource(); var bIsRowEditable = !!(oTable.getSelectedIndices().length === 1); this.getModel("worklistView").setProperty("/IsRowEditable", bIsRowEditable); }, ) :::::::Worklist.view.xml(syntax)::: <Button icon="sap-icon://edit" enabled="{worklistView>/IsRowEditable}" id="test"></Button>
  • Posted on Jul 10, 2020 at 10:57 AM

    Hello Team,

    Can anyone please help me in this issue.

    Thanks & Reagrds,

    Subrata Roy

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 10, 2020 at 07:27 PM

    Check the below plunker example . You need to do this with the help of binding.

    https://plnkr.co/edit/PvByWXV7jWZUyW7F

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 20, 2020 at 11:35 AM
    -2

    In worklistcontrller.js

    var that = this;

    then in the onTableSelection function

    var oTable = that.getView().byId("table");
    var aSelectedItems = oTable.getSelectedItems();
    if (aSelectedItems.length > 0) {
    that.getView().byId("test").setEnabled(true);
    }
    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.