1

在按下回车按钮后,我试图在 UI5 的覆盖容器中放置一个名片控件。我的代码不起作用,我似乎无法弄清楚原因。对此的任何帮助表示赞赏。我的代码如下:

var oButton2 = new sap.ui.commons.Button({
text : "Enter",
style: sap.ui.commons.ButtonStyle.Emph,
width: "75px", 
press : function() {var oOverlayContainer = new sap.ui.ux3.OverlayContainer();
    oOverlayContainer.open();
    oOverlayContainer.addContent( 
        function() {var oVCard = new sap.suite.ui.commons.BusinessCard({
            firstTitle:  new sap.ui.commons.Label({id:"vcard1-name-label",text:"White, Helen",tooltip:"White, Helen"}),
            iconPath: "/XMII/CM/MIIDemos/TimeAttendance/images/AtoS_sm.jpg",
            secondTitle: "Sales Contact at Customer Side",
            imageTooltip:"White, Helen",
            width: "424px"
            });
        var oContentCard = new sap.ui.commons.layout.MatrixLayout({widths:["20px", "100px"]});
        var oCell = new sap.ui.commons.layout.MatrixLayoutCell({hAlign:sap.ui.commons.layout.HAlign.Center});
        oCell.addContent(new sap.ui.commons.TextView({text:"Phone:"}));
        oContentCard.createRow(oCell, new sap.ui.commons.TextView({text:"+41 (635) 457-2875"}));

        oCell = new sap.ui.commons.layout.MatrixLayoutCell({hAlign:sap.ui.commons.layout.HAlign.Center});
        oCell.addContent(new sap.ui.commons.TextView({text:"E-Mail:"}));
        oContentCard.createRow(oCell, new sap.ui.commons.TextView({text:"helen.white@company.com"}));

        oContentCard.createRow(new sap.ui.commons.TextView({text:"Address:"}), new sap.ui.commons.TextView({text:"Diermar-Hopp Allee 16"}));
        oVCard.setContent(oContentCard);
        }
    );
}
})
4

2 回答 2

2

您传递的是函数而不是其结果,您应该这样做:

    var oButton2 = new sap.ui.commons.Button({
    text : "Enter",
    style: sap.ui.commons.ButtonStyle.Emph,
    width: "75px", 
    press : function() {var oOverlayContainer = new sap.ui.ux3.OverlayContainer();
        oOverlayContainer.open();
        oOverlayContainer.addContent( 
            (function() {var oVCard = new sap.suite.ui.commons.BusinessCard({
                firstTitle:  new sap.ui.commons.Label({id:"vcard1-name-label",text:"White, Helen",tooltip:"White, Helen"}),
                iconPath: "/XMII/CM/MIIDemos/TimeAttendance/images/AtoS_sm.jpg",
                secondTitle: "Sales Contact at Customer Side",
                imageTooltip:"White, Helen",
                width: "424px"
                });
            var oContentCard = new sap.ui.commons.layout.MatrixLayout({widths:["20px", "100px"]});
            var oCell = new sap.ui.commons.layout.MatrixLayoutCell({hAlign:sap.ui.commons.layout.HAlign.Center});
            oCell.addContent(new sap.ui.commons.TextView({text:"Phone:"}));
            oContentCard.createRow(oCell, new sap.ui.commons.TextView({text:"+41 (635) 457-2875"}));

            oCell = new sap.ui.commons.layout.MatrixLayoutCell({hAlign:sap.ui.commons.layout.HAlign.Center});
            oCell.addContent(new sap.ui.commons.TextView({text:"E-Mail:"}));
            oContentCard.createRow(oCell, new sap.ui.commons.TextView({text:"helen.white@company.com"}));

            oContentCard.createRow(new sap.ui.commons.TextView({text:"Address:"}), new sap.ui.commons.TextView({text:"Diermar-Hopp Allee 16"}));
            oVCard.setContent(oContentCard);
return oVCard;
            })()
        );
    });
于 2013-11-29T09:10:01.537 回答
0

确保您还添加了以下库:

data-sap-ui-libs="sap.ui.commons, sap.ui.ux3, sap.suite.ui.commons"
于 2014-01-22T11:45:57.173 回答