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

How to hide a context menu option

1 Answer 93 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Hemangajit Dutta
Top achievements
Rank 1
Hemangajit Dutta asked on 27 Nov 2009, 06:46 AM
Hi,
       I am using a tree view where the nodes are using a context menu with two options "Delete"and "View". Depening on certain condition I need to remove the "Delete" menu option from some of the nodes. Could you please let me know how to achieve that?

Thanks
Hemangajit

1 Answer, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 27 Nov 2009, 11:39 AM
Hi Hemangajit,

I suggest you subscribe to OnClientContextMenuShowing event of the treeview and show/hide the "Delete" item in its handler:

<script type="text/javascript">
    function contextMenuShowing(sender, args) {
        if (//condition)
            args.get_menu().findItemByText("Delete").set_visible(false);
        else
            args.get_menu().findItemByText("Delete").set_visible(true);
    }
</script>

Regards,
Yana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
TreeView
Asked by
Hemangajit Dutta
Top achievements
Rank 1
Answers by
Yana
Telerik team
Share this question
or