on 01-03-2014 10:54 AM
Hi All,
I have been trying to develop a simple page with SAPUI5 controls. I have created a Menu Bar and Menu Bar Items with the following kind of code.
var oMenuBar = new sap.ui.commons.MenuBar("menuBar");
var oMenuBarItem1 = new sap.ui.commons.MenuItem("menuBar-item-1",{text:"Home", enabled: true});
oMenuBar.addItem(oMenuBarItem1);
A Menu called "Home" is created. Now if I click on this Menu, it should go to another page. What methods are used to add hyper links to menu items? Can you suggest a sample code?
Thanks & Regards,
Saranya
Hi,
You could attach select event and navigate to an url:
oMenuBarItem1.attachSelect(function navigateEntireToUrl(evt) {
document.location = 'http://www.your_url.com';
});
Kind regards,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Thanks for your reply!
This is the code I typed but it's not working. What could have gone wrong?
var oMenuBar = new sap.ui.commons.MenuBar("menuBar");
var oMenuBarItem1 = new sap.ui.commons.MenuItem("menuBar-item-1",{text:"Project"});
oMenuBar.addItem(oMenuBarItem1);
oMenuBarItem1.attachSelect(function navigateEntireToUrl(evt) {
document.location = 'http://www.google.com';
});
Regards,
Saranya
Try this:
var oMenuBar = new sap.ui.commons.MenuBar("menuBar");
var oMenuBarItem1 = new sap.ui.commons.MenuItem("menuBar-item-1",{text:"Root"});
var oSubMenu1 = new sap.ui.commons.Menu("menuBar-submenu1");
oMenuBarItem1.setSubmenu(oSubMenu1);
var oSubMenuItem1 = new sap.ui.commons.MenuItem("menuBar-subitem-1",{text:"Open Google"});
oSubMenuItem1.attachSelect(function navigateEntireToUrl(evt) {
document.location = 'http://www.google.com';
});
oSubMenu1.addItem(oSubMenuItem1);
oMenuBar.addItem(oMenuBarItem1);
Kind regards,
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.