This is a migrated thread and some comments may be shown as answers.

[Solved] TreeView Context Menu

2 Answers 121 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
John DeVight
Top achievements
Rank 1
John DeVight asked on 03 Jun 2011, 09:56 PM
I am developing extensions to the client API for the Telerik MVC controls and wanted to share the latest extension function.  I have added a function to the TreeView to add context menus to a TreeView that can be configured to be displayed depending on the node that is selected.  The code and sample applications for RAZOR and ASPX can be found at:

http://www.aspnetwiki.com/telerik-mvc:adding-a-context-menu-to-the-treeview

Here is an example of adding two context menus, one for a "project" node and one for a "code file" node:

Layout.NavigationTreeView_OnLoad = function(e) {
    $('#NavigationTreeView').data('tTreeView').addContextMenu({
        evaluateNode: function(treeview, node) {
            var nodeValue = treeview.getItemValue(node);
            var nodeType = nodeValue.split('|')[0].toString();
            return nodeType == 'project';
        },
        menuItems: [{
                text: 'Properties',
                onclick: Layout.NavigationTreeView_OnProperties
            }]
    });
 
    $('#NavigationTreeView').data('tTreeView').addContextMenu({
        evaluateNode: function(treeview, node) {
            var nodeValue = treeview.getItemValue(node);
            var nodeType = nodeValue.split('|')[0].toString();
            return nodeType == 'codefile';
        },
        menuItems: [{
                text: 'Edit',
                onclick: Layout.NavigationTreeView_OnEdit
            }, {
                text: 'Delete',
                onclick: Layout.NavigationTreeView_OnDelete
            }, {
                separator: true
            }, {
                text: 'Properties',
                onclick: Layout.NavigationTreeView_OnProperties
            }]
    });
}

Please share with me any feedback that you have! =)

Regards,

John DeVight

2 Answers, 1 is accepted

Sort by
0
Nagendra
Top achievements
Rank 1
answered on 24 Jun 2011, 04:57 PM
Hi i have not used this, will use in future..but thanks for this because i needed this very badly
0
John DeVight
Top achievements
Rank 1
answered on 24 Jun 2011, 08:35 PM
=)

Let me know if you have any questions.  I now have a sample application that you can download to see how to use all the client api extensions that I have written.  http://www.aspnetwiki.com/page:extending-the-telerik-mvc-client-api

Regards,

John DeVight
Tags
TreeView
Asked by
John DeVight
Top achievements
Rank 1
Answers by
Nagendra
Top achievements
Rank 1
John DeVight
Top achievements
Rank 1
Share this question
or