我有一个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();
}
})
]
});
答案 0 :(得分:1)
使用visible的sap.m.Button属性:
...
new Button({
text: "{i18n>CreatePopupText}",
visible: "{yourModel>TrueOrFalse}"
});
...
如果TrueOrFalse
的属性yourModel
不是布尔值,请使用formatter:
...
new Button({
text: "{i18n>yourButtonText}",
visible: {
path: "yourModel>TrueOrFalse",
formatter: function(sArgument) {
return yourApp.model.formatter.yourMethod(sArgument);
}
}
}
...