on ‎2020 Dec 19 4:50 PM
Hai Experts,
I am trying to add Menu button through JS in dynamically, I have the below code.
onInit: function(evt) {
var that = this;
var bar = this.getView().byId("idbar1");
bar.addContentLeft(new sap.m.Button({
text: "Sample",
press: function() {
that.menuPress();
}
}));
}
menuPress: function() {
var oJSONModel = new sap.ui.model.json.JSONModel({
"Plants": [{
key: "0001",
description: "Plant 0001"
}, {
key: "0002",
description: "Plant 0002"
}, {
key: "0003",
description: "Plant 0003"
}]
});
var oItemTemplate = sap.ui.unified.MenuItem({
text: "{description}"
});
var oMenu1 = new sap.ui.unified.Menu({
items: {
path: "/Plants",
template: oItemTemplate
}
});
oMenu1.setModel(oJSONModel);
oMenu1.open();
},
But I am getting an error while clicking the button.

can anybody guide me to resolve the issue.
Thanks,
Muhsin
Request clarification before answering.
how about adding sap.ui.unified.MenuItem to controller dependency?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
sap.ui.define(["sap/ui/core/mvc/Controller","sap/ui/unified/MenuItem"],function(Controller,MenuItem){"use strict";returnController.extend("",{});});
| User | Count |
|---|---|
| 15 | |
| 9 | |
| 6 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.