SAPUI5 弹出对话框按钮动态可见性
SAPUI5 Popup Dialog Button Dynamic Visibility
我有一个 SAPUI5 弹出对话框,在弹出对话框的页脚部分有几个按钮。
我需要根据模型的值动态设置弹出窗口中按钮的可见性 属性。有什么办法吗
that.oNewAppointmentDialog = new Dialog({
title: "{i18n>CreatePopupTitle}",
content: [
sap.ui.xmlfragment("CreateFrag", "proj.view.fragments.AssignmentCreate", this)
],
buttons: [
new Button({
text: "{i18n>CreatePopupText}",
type: "Ghost",
press: function () {
}
}),
new Button({
text: "{i18n>CreatePopupClearButton}",
type: "Ghost",
press: function () {
}
}),
new Button({
text: "{i18n>CloseButton}",
press: function () {
// Close Button Click Event
that.oNewAppointmentDialog.close();
}
})
]
});
使用 visible property of the sap.m.Button:
...
new Button({
text: "{i18n>CreatePopupText}",
visible: "{yourModel>TrueOrFalse}"
});
...
如果 yourModel
的属性 TrueOrFalse
不是布尔值,则使用 formatter:
...
new Button({
text: "{i18n>yourButtonText}",
visible: {
path: "yourModel>TrueOrFalse",
formatter: function(sArgument) {
return yourApp.model.formatter.yourMethod(sArgument);
}
}
}
...
我有一个 SAPUI5 弹出对话框,在弹出对话框的页脚部分有几个按钮。
我需要根据模型的值动态设置弹出窗口中按钮的可见性 属性。有什么办法吗
that.oNewAppointmentDialog = new Dialog({
title: "{i18n>CreatePopupTitle}",
content: [
sap.ui.xmlfragment("CreateFrag", "proj.view.fragments.AssignmentCreate", this)
],
buttons: [
new Button({
text: "{i18n>CreatePopupText}",
type: "Ghost",
press: function () {
}
}),
new Button({
text: "{i18n>CreatePopupClearButton}",
type: "Ghost",
press: function () {
}
}),
new Button({
text: "{i18n>CloseButton}",
press: function () {
// Close Button Click Event
that.oNewAppointmentDialog.close();
}
})
]
});
使用 visible property of the sap.m.Button:
...
new Button({
text: "{i18n>CreatePopupText}",
visible: "{yourModel>TrueOrFalse}"
});
...
如果 yourModel
的属性 TrueOrFalse
不是布尔值,则使用 formatter:
...
new Button({
text: "{i18n>yourButtonText}",
visible: {
path: "yourModel>TrueOrFalse",
formatter: function(sArgument) {
return yourApp.model.formatter.yourMethod(sArgument);
}
}
}
...