Select node on right click

4 posts, 0 answers
  1. Gregory
    Gregory avatar
    9 posts
    Member since:
    Dec 2014

    Posted 23 Oct Link to this post

    How can we select the node that is clicked on by a right click event?  I am trying to pass the selected node's id on a context menu select event but unless the user left clicks on the node to select it first, the last selected node information gets sent, if one was even selected.

    This may be fairly basic, but I can't find any examples of this.

    Thanks.

  2. Neli
    Admin
    Neli avatar
    54 posts

    Posted 24 Oct Link to this post

    Hi Gregory,

    The following article from our documentation shows how the ContextMenu could be implemented on the right click event of the TreeView widget. 

    As it is shown in the example, on the select event of the ContextMenu the node data could be get by using TreeView dataItem method.
    var nodeData = $("#treeview").data("kendoTreeView").dataItem(node);

    Regards,
    Neli
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Gregory
    Gregory avatar
    9 posts
    Member since:
    Dec 2014

    Posted 24 Oct in reply to Neli Link to this post

    Thank you for the reply.

    This doesn't seem to give me the node that the context menu / right click event was taken on.  $(e.target) in the onSelect event of the context menu returns the entire treeview.

        function cmResourceActions_onSelect(e) {
            var tvDependencyViewer = $("#tvDependencyViewer").data("kendoTreeView");
            alert($(e.target).text());

    ....

     

  4. Neli
    Admin
    Neli avatar
    54 posts

    Posted 25 Oct Link to this post

    Hi Gregory,

    $(e.target) is returning the selected node as an jQuery object. To get the data of the node, the dataItem method should be used.
    select: function(e) {           
    var node = $(e.target);  
    // you can get the node data (e.g. id) via the TreeView dataItem method:
    var nodeData = $("#treeview").data("kendoTreeView").dataItem(node);
    }

    I made a simple Dojo based on the article I have sent previously. On selecting an item form the ContextMenu, the node from the TreeView and its  data are console logged.

    This could be observed also on the linked screencast.

    Regards,
    Neli
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top