在SAPUI5中调整对话框大小后如何触发事件?

时间:2018-07-30 12:41:19

标签: sapui5

我有一个sap.m.Dialog。

调整对话框大小后,我需要触发事件处理程序。

当SAPUI5中的对话框没有调整大小事件时,如何注册此事件处理程序。

2 个答案:

答案 0 :(得分:2)

根据文档sap.m.Dialog具有可调整大小属性,该属性允许sap.m.Dialog具有调整大小处理程序。如果将该属性设置为,您可以使用sap.ui.core.ReisizeHandler处理该事件。

也请参见下面关于jsbin的example

var oDialogResize = new sap.m.Dialog('resizableDialog', {
            title: "Resizable Dialog",
            resizable: true,
            content: [
                new sap.m.Label("label1",{text: ""}),
                new sap.m.ToolbarSpacer(),
                new sap.m.Label("label2",{text: ""})
            ],
            endButton: new sap.m.Button('resizeDialogCloseButton', {
                text: "Cancel", press: function () {
                    oDialogResize.close();
                }
            })
        });



var oButton = new sap.m.Button({
  text: 'Open',
  press: function() {
    oDialogResize.open();
  }
  
}).placeAt('content');

oButton.addEventDelegate({
     "onAfterRendering": function () {
          sap.ui.core.ResizeHandler.register(oDialogResize, function(oEvent){
            console.log("ResizeEvent");
            sap.ui.getCore().byId("label1").setText(" W:" + oEvent.size.width);
             sap.ui.getCore().byId("label2").setText(" H: " + oEvent.size.height);
          });
     }
}, this);
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>JS Bin</title>
    <script 
            src="https://openui5.hana.ondemand.com/resources/sap-ui-core.js" 
            id="sap-ui-bootstrap" 
            data-sap-ui-theme="sap_bluecrystal" 
            data-sap-ui-xx-bindingSyntax="complex" 
            data-sap-ui-libs="sap.m"></script>
  </head>
  <body class="sapUiBody">
    <div id='content'></div>
  </body>
</html>

答案 1 :(得分:1)

将事件侦听器添加到对话框:

UIImageView