SAPUI5弹出对话框按钮动态可见性

时间:2018-11-26 12:53:54

标签: sapui5

我有一个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();
                                }
                            })
                            ]

                });

1 个答案:

答案 0 :(得分:1)

使用visiblesap.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);
      }
    }
  }
...