SAPUI5:TableSelectDialog获取页脚中的按钮

时间:2019-05-06 11:21:31

标签: button dialog sapui5

我想以某种方式获得TableSelectDialog的确认和取消按钮以更改文本。但是我不知道该怎么做。

在我看来,最好的解决方案是在片段中设置按钮,但没有sap.m.Dialog中的聚合“按钮”。那么如何在TableSelectDialog的工具栏中使用自己的文本设置按钮?

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

2 个答案:

答案 0 :(得分:0)

如果我正确理解,您正在尝试更改“确定”和“取消”按钮的文本。

为此,即使我希望其他人提供更好的解决方案,您也可以尝试以下操作:

1)为您的id分配一个TableSelectDialog

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

...

</TableSelectDialog>

2)在打开对话框之前,请尝试以下操作:

//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");

答案 1 :(得分:0)

从UI5版本 1.68.x 开始,sap.m.TableSelectDialogsap.m.SelectDialog提供了一个名为confirmButtonText 1 的新属性。

<TableSelectDialog xmlns="sap.m"
  confirmButtonText="{i18n>myOwnConfirmText}"
  ....
</TableSelectDialog>

但是,目前没有公共API可以自定义取消按钮。您将不得不依靠以前的解决方案(访问我们都强烈反对的私有API)或仅保留标准文本,这不仅改善了向上兼容性,还改善了其他Fiori应用程序的UI一致性。


1 commit:5795433