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

[Solved] OnClientContextMenuShowing not fired for submenus

4 Answers 141 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
relper
Top achievements
Rank 1
relper asked on 02 Feb 2008, 08:58 PM

I have a context menu with submenus in a RadTreeView. When I hover over one item that has a submenu, the submenu opens but the OnClientContextMenuShowing event doesn’t fire. Is there another event I should be looking for? How can I handle the enabled/disabled states of the submenu items?

Thanks!

4 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 04 Feb 2008, 04:47 PM
Hi relper,

I tried to reproduce the problem against the latest official Web.UI build, but to no avail. Attached, please find a small and running project as part of my local tests. Download it and give it a go.

What am I missing?

Regards,
Nick
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
relper
Top achievements
Rank 1
answered on 04 Feb 2008, 06:17 PM

The problem may be because I’m using a build 074437_Telerik.Web.UI_2007_3_1323_trial_hotfix.zip available in another post (http://www.telerik.com/community/forums/thread/b311D-bbtkdc.aspx). Anyway, I modified your code and was able to repro the problem. I forgot to mention I’m loading the context menu from a file and attaching it to the tree programmatically. The changes I made to your sample were:

1)      Added the DLLs from the build above

2)      Added the code below to Page_Load event

        if (!Page.IsPostBack)

        {

            RadTreeViewContextMenu contextMenu1 = new RadTreeViewContextMenu();

            contextMenu1.LoadContentFile("~/App_Data/ContextMenu1.xml");

            contextMenu1.ID = "contextMenu1";

            RadTreeView1.ContextMenus.Add(contextMenu1);

        }

3)      Added the ContextMenu1.xml file (below) to App_Data

<?xml version="1.0" encoding="utf-8" ?>

<Menu>

        <Group Flow="Horizontal">

                <Item Text="Menu1" Value="Menu1">

                </Item>

                <Item Text="Menu2" Value="Menu2">

                        <Group Flow="Vertical">

                                <Item Text="Submenu1" Value="Submenu1" />

                                <Item Text="Submenu2" Value="Submenu2" />

                                <Item Text="Submenu3" Value="Submenu3"/>

                        </Group>

                </Item>

                <Item Text="Menu3" Value="Menu3" >

                </Item>

        </Group>

</Menu>

You will see the problem when you hover over the “Menu2” item and the submenu appears but no OnClientContextMenuShowing event is fired.

 

Thanks!

0
Accepted
Dimitar Milushev
Telerik team
answered on 04 Feb 2008, 06:40 PM
Hi relper,

The OnClientContextMenuShowing event is fired when right-clicking on a RadTreeNode. I believe what you need is one of the RadMenu client events and specifically 'OnClientItemOpening'. For example, in your case, you need to use the following code:

RadTreeViewContextMenu contextMenu1 = new RadTreeViewContextMenu(); 
 
contextMenu1.LoadContentFile("~/App_Data/ContextMenu1.xml"); 
 
contextMenu1.ID = "contextMenu1"
 
contextMenu1.OnClientItemOpening = "OnClientItemOpening"

You can read more about the RadMenu client-side events in the RadMenu help at http://www.telerik.com/help/radcontrols/prometheus/?MenuOverview.html

All the best,
Dimitar Milushev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
relper
Top achievements
Rank 1
answered on 04 Feb 2008, 07:01 PM
That was it. Thanks a lot Dimitar!
Tags
TreeView
Asked by
relper
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
relper
Top achievements
Rank 1
Dimitar Milushev
Telerik team
Share this question
or