效果
代码
<<span style="color:#3f7f7f">script>
//Function to handle the select event of the items
var handleSelect = function(oEvent) {
alert(oEvent.getParameter("item").getId());
};
//create menu
var oMenu = new sap.ui.commons.Menu("menu");
oMenu.setAriaDescription("Menu");
//create item
var oMenuItem1 = new sap.ui.commons.MenuItem("item1", {
text : "子菜单1"
});
var oMenuItem2 = new sap.ui.commons.MenuItem("item2", {
text : "子菜单2"
});
var oMenu_sub1 = new sap.ui.commons.Menu("subM");
var oMenuItem11 = new sap.ui.commons.MenuItem("item11", {
text : "子菜单11"
});
var oMenuItem12 = new sap.ui.commons.MenuItem("item12", {
text : "子菜单12"
});
oMenuItem1.setSubmenu(oMenu_sub1);
oMenu_sub1.addItem(oMenuItem11);
oMenu_sub1.addItem(oMenuItem12);
oMenu.addItem(oMenuItem1);
oMenu.addItem(oMenuItem2);
//event
oMenuItem2.attachSelect(handleSelect);
oMenuItem11.attachSelect(handleSelect);
oMenuItem12.attachSelect(handleSelect);
// Create a Link which opens the menu on click
var oLink1 = new sap.ui.commons.Link("link1", {
text : "Menu Click"
});
oLink1
.attachPress(function() {
var eDock = sap.ui.core.Popup.Dock;
oMenu
.open(
false ,
oLink1.getFocusDomRef() ,
eDock.BeginTop,
eDock.BeginBottom,
oLink1.getDomRef()
);
});
// Attach the link to the page
oLink1.placeAt("content");
</<span style="color:#3f7f7f">script>
友情推广:
第一课堂HANA系统搭建完成,公网双IP访问,速度有保证,
进第一课堂群139446252,免费领取HANA测试账号。
申请时验证信息可输入来自本博客