<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: Issue while bind menu items dynamically in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/issue-while-bind-menu-items-dynamically/qaa-p/12337625#M4621072</link>
    <description>&lt;P&gt;add these snippet in init , or just before you are using Menu and MenuItem &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;jQuery.sap.require("sap.ui.unified.Menu") ;

jQuery.sap.require("sap.ui.unified.MenuItem");

//your Menu code goes here 

&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 20 Dec 2020 05:54:31 GMT</pubDate>
    <dc:creator>sreehari_vpillai</dc:creator>
    <dc:date>2020-12-20T05:54:31Z</dc:date>
    <item>
      <title>Issue while bind menu items dynamically</title>
      <link>https://community.sap.com/t5/technology-q-a/issue-while-bind-menu-items-dynamically/qaq-p/12337617</link>
      <description>&lt;P&gt;Hai Experts,&lt;/P&gt;
  &lt;P&gt;I am trying to add Menu button through JS in dynamically, I have the below code.&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;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();
		},&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;But I am getting an error while clicking the button. &lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1873526-error.png" /&gt;&lt;/P&gt;
  &lt;P&gt;can anybody guide me to resolve the issue.&lt;/P&gt;
  &lt;P&gt;Thanks,&lt;/P&gt;
  &lt;P&gt;Muhsin&lt;/P&gt;</description>
      <pubDate>Sat, 19 Dec 2020 16:50:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/issue-while-bind-menu-items-dynamically/qaq-p/12337617</guid>
      <dc:creator>muhsin_panakkal</dc:creator>
      <dc:date>2020-12-19T16:50:10Z</dc:date>
    </item>
    <item>
      <title>Re: Issue while bind menu items dynamically</title>
      <link>https://community.sap.com/t5/technology-q-a/issue-while-bind-menu-items-dynamically/qaa-p/12337618#M4621065</link>
      <description>&lt;P&gt;Think you missed the "new" keyword for creating an instance of sap.ui.unified.MenuItem&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;... 
var oItemTemplae = new sap.ui.unified.MenuItem( ...&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 19 Dec 2020 17:07:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/issue-while-bind-menu-items-dynamically/qaa-p/12337618#M4621065</guid>
      <dc:creator>pfefferf</dc:creator>
      <dc:date>2020-12-19T17:07:01Z</dc:date>
    </item>
    <item>
      <title>Re: Issue while bind menu items dynamically</title>
      <link>https://community.sap.com/t5/technology-q-a/issue-while-bind-menu-items-dynamically/qaa-p/12337619#M4621066</link>
      <description>&lt;P&gt;Dear Florian,&lt;/P&gt;&lt;P&gt;Thanks for your response, I tried with above also, giving the same error.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Muhsin&lt;/P&gt;</description>
      <pubDate>Sat, 19 Dec 2020 17:12:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/issue-while-bind-menu-items-dynamically/qaa-p/12337619#M4621066</guid>
      <dc:creator>muhsin_panakkal</dc:creator>
      <dc:date>2020-12-19T17:12:16Z</dc:date>
    </item>
    <item>
      <title>Re: Issue while bind menu items dynamically</title>
      <link>https://community.sap.com/t5/technology-q-a/issue-while-bind-menu-items-dynamically/qaa-p/12337620#M4621067</link>
      <description>&lt;P&gt;how about adding sap.ui.unified.MenuItem to controller dependency?&lt;/P&gt;</description>
      <pubDate>Sat, 19 Dec 2020 17:16:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/issue-while-bind-menu-items-dynamically/qaa-p/12337620#M4621067</guid>
      <dc:creator>junwu</dc:creator>
      <dc:date>2020-12-19T17:16:13Z</dc:date>
    </item>
    <item>
      <title>Re: Issue while bind menu items dynamically</title>
      <link>https://community.sap.com/t5/technology-q-a/issue-while-bind-menu-items-dynamically/qaa-p/12337621#M4621068</link>
      <description>&lt;P&gt;Hai Jun Wu,&lt;/P&gt;&lt;P&gt;Can you please explain this..?&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Muhsin&lt;/P&gt;</description>
      <pubDate>Sun, 20 Dec 2020 03:42:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/issue-while-bind-menu-items-dynamically/qaa-p/12337621#M4621068</guid>
      <dc:creator>muhsin_panakkal</dc:creator>
      <dc:date>2020-12-20T03:42:30Z</dc:date>
    </item>
    <item>
      <title>Re: Issue while bind menu items dynamically</title>
      <link>https://community.sap.com/t5/technology-q-a/issue-while-bind-menu-items-dynamically/qaa-p/12337622#M4621069</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;sap.ui.define(["sap/ui/core/mvc/Controller","sap/ui/unified/MenuItem"],function(Controller,MenuItem){"use strict";returnController.extend("",{});});&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 20 Dec 2020 03:45:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/issue-while-bind-menu-items-dynamically/qaa-p/12337622#M4621069</guid>
      <dc:creator>junwu</dc:creator>
      <dc:date>2020-12-20T03:45:52Z</dc:date>
    </item>
    <item>
      <title>Re: Issue while bind menu items dynamically</title>
      <link>https://community.sap.com/t5/technology-q-a/issue-while-bind-menu-items-dynamically/qaa-p/12337623#M4621070</link>
      <description>&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1871604-answer.jpg" /&gt;&lt;/P&gt;&lt;P&gt;Adding to Florian's reply , this must be missing 'new" keyword . But, as you already tried that and facing the same error again ( which is highly unlikely ) , can you share the screenshot of the error you are facing after adding new statement ? &lt;/P&gt;&lt;P&gt;aslo , click on "View1.controller.js?eval;58" line from the error control , which takes you to the live running code in browser. See if "new" is reflecting there &lt;/P&gt;&lt;P&gt;Sree&lt;/P&gt;</description>
      <pubDate>Sun, 20 Dec 2020 04:52:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/issue-while-bind-menu-items-dynamically/qaa-p/12337623#M4621070</guid>
      <dc:creator>sreehari_vpillai</dc:creator>
      <dc:date>2020-12-20T04:52:22Z</dc:date>
    </item>
    <item>
      <title>Re: Issue while bind menu items dynamically</title>
      <link>https://community.sap.com/t5/technology-q-a/issue-while-bind-menu-items-dynamically/qaa-p/12337624#M4621071</link>
      <description>&lt;P&gt;Dear Sreehari,&lt;/P&gt;&lt;P&gt;I tried with new instance, I am getting the same error. Kindly find the below.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;menuPress: function() {
			var oJSONModel = new sap.ui.model.json.JSONModel({&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;				"Plants": [{&lt;BR /&gt;
					key: "0001",
					description: "Plant 0001"
				}, {
					key: "0002",
					description: "Plant 0002"
				}, {
					key: "0003",
					description: "Plant 0003"
				}]
			});
			var oItemTemplate = new sap.ui.unified.MenuItem({&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;				text: "{description}"
			});
			var oMenu1 = new sap.ui.unified.Menu({
				items: {
					path: "/Plants",
					template: oItemTemplate
				}
			});&lt;BR /&gt;
			oMenu1.setModel(oJSONModel);
			oMenu1.open();
		},&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1873528-error-1.png" /&gt;&lt;/P&gt;&lt;P&gt;and in the error, "View1.controller.js?eval;57" &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1873529-error-1-1.png" /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Muhsin&lt;/P&gt;</description>
      <pubDate>Sun, 20 Dec 2020 05:50:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/issue-while-bind-menu-items-dynamically/qaa-p/12337624#M4621071</guid>
      <dc:creator>muhsin_panakkal</dc:creator>
      <dc:date>2020-12-20T05:50:11Z</dc:date>
    </item>
    <item>
      <title>Re: Issue while bind menu items dynamically</title>
      <link>https://community.sap.com/t5/technology-q-a/issue-while-bind-menu-items-dynamically/qaa-p/12337625#M4621072</link>
      <description>&lt;P&gt;add these snippet in init , or just before you are using Menu and MenuItem &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;jQuery.sap.require("sap.ui.unified.Menu") ;

jQuery.sap.require("sap.ui.unified.MenuItem");

//your Menu code goes here 

&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 20 Dec 2020 05:54:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/issue-while-bind-menu-items-dynamically/qaa-p/12337625#M4621072</guid>
      <dc:creator>sreehari_vpillai</dc:creator>
      <dc:date>2020-12-20T05:54:31Z</dc:date>
    </item>
    <item>
      <title>Re: Issue while bind menu items dynamically</title>
      <link>https://community.sap.com/t5/technology-q-a/issue-while-bind-menu-items-dynamically/qaa-p/12337626#M4621073</link>
      <description>&lt;P&gt;Dear Jun Wu,&lt;/P&gt;&lt;P&gt;I tried the above method, which resolved my issue. Thanks for your help.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Muhsin&lt;/P&gt;</description>
      <pubDate>Thu, 24 Dec 2020 11:34:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/issue-while-bind-menu-items-dynamically/qaa-p/12337626#M4621073</guid>
      <dc:creator>muhsin_panakkal</dc:creator>
      <dc:date>2020-12-24T11:34:40Z</dc:date>
    </item>
  </channel>
</rss>

