[英]How to add a close button to a JavaScript dialog in SAPUI5?
我正在尝试向 javaScript 视图对话框添加一个按钮。 不幸的是,按钮没有显示(标题按钮)实际上,我希望对话框在角落有另一个按钮,关闭对话框
this.oWarningMessageDialog = new Dialog({
type: DialogType.Message,
title: this._oBundle.getText("PaymentPostponement"),
state: ValueState.Warning,
Header: new Button({
type: ButtonType.Reject,
icon: "sap-icon://decline",
press: function (oEvent) {
this.oWarningMessageDialog.close()
this.oWarningMessageDialog = null
Core.byId("ApproveMessageText").destroy()
}.bind(this)
}),
beginButton: new Button({
type: ButtonType.Reject,
text: this._oBundle.getText("Postpone"),
icon: "sap-icon://decline",
如果您需要图像中指定的确切外观,则需要使用“customHeader”聚合。 代码如下:-
this.oWarningMessageDialog = new Dialog({
type: DialogType.Message,
state: ValueState.Warning,
customHeader: [
new sap.m.Bar({
/* either use an icon */
contentRight: new sap.ui.core.Icon({
src : "sap-icon://decline",
useIconTooltip : false,
color : "#f33334",
press : function (oEvent) {
this.oWarningMessageDialog.close();
this.oWarningMessageDialog = null;
Core.byId("ApproveMessageText").destroy()
}.bind(this)
}).addStyleClass("sapUiMediumMarginBottom"),
/* or you can even use a button */
// contentRight: new Button({
// type: ButtonType.Transparent,
// icon: "sap-icon://decline",
// width: "20px",
// press: function (oEvent) {
// this.oWarningMessageDialog.close();
// this.oWarningMessageDialog = null;
// }.bind(this)
// }).addStyleClass("sapUiSmallMarginBottom"),
contentMiddle : [
new sap.m.Title({
text :this._oBundle.getText("PaymentPostponement")
}),
new sap.ui.core.Icon({
src : "sap-icon://message-warning",
useIconTooltip : false,
color : "#E69A17"
})
]
})
],
beginButton: new Button({
type: ButtonType.Reject,
text: this._oBundle.getText("Postpone"),
icon: "sap-icon://decline"
})
});
或者,包含关闭按钮的正确方法是使用“endButton”聚合。 但这将在对话框的页脚中显示按钮。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.