Error when all context menus are not visible

3 posts, 0 answers
  1. Doron Yaacoby
    Doron Yaacoby avatar
    4 posts
    Member since:
    Mar 2009

    Posted 21 May 2009 Link to this post

    I have a page with a tree-view and two context menus that are not visible by default. When I select an item in the tree, I get a javascript error: 'Telerik.Web.UI.RadContextMenu is null or not an object'. I've fixed it for now by adding a "dummy" context-menu with no items in it (but with the Visible property set to 'true'), but I would like to know if there is a better solution.

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 26 May 2009 Link to this post

    Hi Doron,

    I guess you want not to show the RadContextMneu for some nodes of treeview. If so, better way to accomplish this is by canceling the event in OnClientContextMenuShowing method after checking the node that the context menu is being opened for.

    <telerik:radtreeview id="RadTreeView1" runat="server" OnClientContextMenuShowing="ClientContextMenuShowing"
    <telerik:RadTreeViewContextMenu ID="ContextMenu"
            <telerik:RadMenuItem Text="Copy" Value="Copy"></telerik:RadMenuItem> 
            <telerik:RadMenuItem Text="Edit" Value="Edit"></telerik:RadMenuItem> 
    <telerik:RadTreeNode runat="server" Text="Peripherals"
        <telerik:RadTreeNode runat="server" Text="Printers"></telerik:RadTreeNode> 
        <telerik:RadTreeNode runat="server" Text="Scanners"></telerik:RadTreeNode> 

    <script type="text/javascript"
    function ClientContextMenuShowing(sender, eventArgs) 
     var node = eventArgs.get_node();    
     var menu = eventArgs.get_menu();    
     if (node.get_text() == "Printers"
    Note: eventArgs.set_cancel(true) will cancel the event and the contextmenu is not shown.

  3. Veselin Vasilev
    Veselin Vasilev avatar
    2992 posts

    Posted 26 May 2009 Link to this post

    Hi Doron,

    in addition, instead of setting the Visible property to False of the context menus please use


    Veselin Vasilev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top