我有右键菜单(contentmenu)但它只显示在一个静态位置(int under bottom)。你能帮助我吗?我使用这段代码:
<ul class ="k-column-menu" id="contextmenu" style=" display:none; position: absolute; background-color:white; border-style:solid; border-width:1px;" >
<li>Genres</li>
<li>About</li>
<li>@Html.ActionLink("Contact", "Contact", "Home")</li>
和这个
$(document).ready(function () {
$(document).bind('contextmenu', function (event){
$("#contextmenu").kendoMenu({ position: "relative", orientation: "vertical" }).show();
event.preventDefault();
});
$(document).bind('click', function () {
$("#contextmenu").hide();
});
});
我解决了这个问题:
$(document).ready(function () {
$(document).bind('contextmenu', function (event){
$("#contextmenu").css({ "top": event.pageY + "px", "left": event.pageX + "px" }).kendoMenu({orientation: "vertical"}).show();
event.preventDefault();
});
$(document).bind('click', function () {
$("#contextmenu").hide();
});
});
我想问另一个问题。如何才能使此菜单仅在右键单击列标题时显示,而在页面或表格中没有其他地方
答案 0 :(得分:1)
您只需在<th>
bind
时指定click event
标记。
更新了链接:
另一次更新
根据您的要求 another example ,您只需要更改
这样:
$(document).bind('contextmenu', function (event){
$("#contextmenu").kendoMenu({ position: "relative", orientation: "vertical"}).show();
event.preventDefault();
});
到此:
$(".k-header").bind('contextmenu', function (event){
$("#contextmenu").kendoMenu({ position: "relative", orientation: "vertical"}).show();
event.preventDefault();
});