问题描述
我正在尝试向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"),
解决方法
如果需要图像中指定的确切外观,则需要使用'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",color : "#E69A17"
})
]
})
],beginButton: new Button({
type: ButtonType.Reject,text: this._oBundle.getText("Postpone"),icon: "sap-icon://decline"
})
});
或者,包含关闭按钮的正确方法是使用“ endButton”聚合。但这将在对话框的页脚中显示按钮。