SAPUI5: sap.m.MenuButton is not a constructor

Hello Experts,

I am trying to run a SAPUI5 application that I wrote but I receive the following error:

sap.m.MenuButton is not a constructor

My code snippet:

		var oBar = new sap.m.Bar({});
		...
		oBar.addContentLeft(new sap.m.MenuButton({tooltip: "{i18n>generic.Refresh}", press: function() { }, icon: "sap-icon://generic/refresh", buttonMode: "Split"}));
...



Any suggestions?

Regards.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Jul 02, 2017 at 08:39 AM

    Okay, I figured it out...

    I was missing the following library declaration:

    data-sap-ui-libs="..., sap.ui.unified, ..."
    
    Add comment
    10|10000 characters needed characters exceeded

  • Jul 02, 2017 at 07:20 AM
    -1

    Hello Effi,

    Please check the sap.m.MenuButton documentation in the SAPUI5 Explored application:

    Best regards

    Frank

    Add comment
    10|10000 characters needed characters exceeded

    • Hello Frank,

      Thank you for your answer.

      I took the code that I wrote & put it in JS Bin. It is working.

      ...
      
          var page = this.getView().byId("page");
          page.setCustomHeader(new sap.m.Bar({
            contentLeft: [
              new sap.m.ToolbarSpacer(),
              new sap.m.MenuButton({tooltip: "Test", press: function() {  }, icon: "sap-icon://play", buttonMode: sap.m.MenuButtonMode.Split}),
              new sap.m.Button({
                text: "Next"
              })
            ]
          }));
      
      ...

      For some reason, it does not work when I deploy it on my server (SAP Netweaver 7.5).

Skip to Content