1

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

http://jsfiddle.net/doonot/xWjSz/

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

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

4

1 回答 1

2

嗨,请参阅此演示 http://jsfiddle.net/hYJPv/1/ http://jsfiddle.net/hYJPv/(已修复问题)此处的差异方法http://jsfiddle.net/UeqBk/for_Dooonot_from_Tats_innit/

你会rightclick得到一个警报。

代码

$(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} );
});
​
于 2012-05-02T11:57:12.630 回答