Java 右键单击树状视图中的项目时显示菜单

Java 右键单击树状视图中的项目时显示菜单,java,javascript,jquery,html,treeview,Java,Javascript,Jquery,Html,Treeview,我有一个树状视图,我想为不同的项目添加右键单击支持。我就是这样做的: 该菜单仅显示第一个根模块(右键单击后),而不显示其余根模块。你能告诉我,为了获得所有根模块的菜单,我必须更改什么吗 非常感谢,我非常感谢您的回答。你好请查看此演示或(修复问题)或这里的不同方法 在上右键单击,您将收到警报 代码 $(document).ready(function() { // If you want to disable showing the context menu when right cli

我有一个树状视图,我想为不同的项目添加右键单击支持。我就是这样做的:

该菜单仅显示第一个根模块(右键单击后),而不显示其余根模块。你能告诉我,为了获得所有根模块的菜单,我必须更改什么吗


非常感谢,我非常感谢您的回答。

你好请查看此演示(修复问题)这里的不同方法

上右键单击
,您将收到警报

代码

$(document).ready(function()
{
    // If you want to disable showing the context menu when right clicking
    // on the document, the code below would do the trick.
    $(document).bind("contextmenu",function(e)
    {
        alert('right click capture');
        return false;
    }); 

    var $tree = $("#tree").kendoTreeView(
    {
        select: function (event)
        {
            var $item = $(event.node);
            console.log( $item );
            alert( "selected" );
        }
    });


    // Find the item you want to select...
    var $selected = $('#selected');
    var $treePath = $selected.parentsUntil($tree, "li");

    var treeView = $tree.data('kendoTreeView');

    // Expand the tree in order to show the selected item
    treeView.expand( $treePath );

    // Gotta make both calls...
    treeView.select( $selected );
    treeView.trigger( 'select', {node: $selected} );
});
​

您好,我可以给您一个非常简单的JSFIDLE,它能为您工作吗?它能捕获您的右键点击吗?请让我知道,如果这适合你布鲁夫将更新使用树状视图的答案,有一个很好的:)cheerios!是的,那太好了。给我一分钟,我会在上面添加我的树状视图的一部分!顺便说一句,我正在使用jquery-treeview.Saweet给我2分钟!干杯!谢谢你!但我不确定这是否真的是我所需要的。我能够捕获右键单击,甚至显示菜单,但仅限于树视图中的第一项。它不适用于其余项目。我不知道,怎么做。你知道吗?@dooonot probles bruv,你是指在我给出的例子中还是在你的样本中?抱歉,如果这听起来有点晦涩:只是确保我理解正确你的意思!干杯!在我提供的示例中。我真的在用这个。@dooonot saweet!啊哈,好的,等一下,给我10。这是你需要的:让我知道布鲁夫B-!干杯