Search code examples
sapui5

sap.m.TableSelectDialog: Customize Button Texts in the Footer


Somehow I want to get the Confirm and the Cancel button of a TableSelectDialog for changing the text. But I don't know how to do it properly.

In my opinion, the best solution is to set the buttons in the fragment but there are no <buttons> aggregations like in the sap.m.Dialog. So how can I set my buttons with my own text in the footer toolbar?

<TableSelectDialog xmlns="sap.m"
  noDataText="No Products Found"
  title="Select Product"
  search=".handleSearch"
  confirm=".handleClose" -> want this button
  cancel=".handleClose"  -> want this button
  multiSelect="true"
  ....
</TableSelectDialog>

Solution

  • If I understand correctly you are trying to change the texts of the OK and Cancel button.

    In order to do that, even though I hope someone else offers a better solution, you could try the following:

    1) Assign an id to your TableSelectDialog:

    <TableSelectDialog
        noDataText="No Products Found"
        title="Select Product"
        search="handleSearch"
        confirm="handleClose"
        cancel="handleClose"
        multiSelect="true"
        id="IdTableSelectionDialog">
    
    ...
    
    </TableSelectDialog>
    

    2) Before opening the dialog try the following:

    //Change the OK button text
    sap.ui.getCore().byId("IdTableSelectionDialog")._getOkButton().setText("New value you want to use");
    
    //Change the Cancel button text
    sap.ui.getCore().byId("IdTableSelectionDialog")._getCancelButton().setText("New value you want to use");