How to hide a context menu option

2 posts, 0 answers
  1. Hemangajit Dutta
    Hemangajit Dutta avatar
    6 posts
    Member since:
    Nov 2009

    Posted 27 Nov 2009 Link to this post

    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
  2. Yana
    Admin
    Yana avatar
    5013 posts

    Posted 27 Nov 2009 Link to this post

    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.
Back to Top