我想向我的列表组件触发上下文菜单事件。我正在使用以下编码,但它不起作用。我在哪里做错了?请让我知道我应该如何正确使用此事件。这是我的代码;我的列表组件:
<List
id="commentListView"
items="{/TicketItemModel/COMMENTS}"
visible="{/TicketCommentListVisibility}"
mode="SingleSelectMaster"
includeItemInSelection="true"
class="todo-comment-list">
{/* Items here.. */}
</List>
我的 controller.js 文件:
this.getView().byId("commentListView").attachBeforeOpenContextMenu(??,_this.handleShowCommentContextMenu(),??);
我不确切知道应该将哪些参数传递给函数
这是我调用的主要功能代码:
handleShowCommentContextMenu:function(oEvent){
var _this = this;
if(oEvent){
var listItemBase = oEvent.getSource();
if(!_this.popupMenu){
_this.popupMenu = new Menu({
items:[
new sap.ui.unified.MenuItem({
text:"Settings",
select:function(){
}
}),
]
})
_this.getView().addDependent(_this.popupMenu);
}
var eDock = sap.ui.core.Popup.Dock;
_this.popupMenu.open(false, listItemBase, eDock.BeginTop, eDock.BeginBottom, listItemBase);
}
}