Reputation: 4958
I've a SAPUI5 popup dialog which has several buttons in the footer section of the popup.
I need to dynamically set the visibility of a button in the popup based on a value of a model property. Is there any way to do that.
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();
}
})
]
});
Upvotes: 0
Views: 1798
Reputation: 1580
use the visible property of the sap.m.Button:
...
new Button({
text: "{i18n>CreatePopupText}",
visible: "{yourModel>TrueOrFalse}"
});
...
in case the attribute TrueOrFalse
of yourModel
is not a Boolean then use a formatter:
...
new Button({
text: "{i18n>yourButtonText}",
visible: {
path: "yourModel>TrueOrFalse",
formatter: function(sArgument) {
return yourApp.model.formatter.yourMethod(sArgument);
}
}
}
...
Upvotes: 1