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

close top level menu item after child menu selection

3 Answers 108 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 26 Nov 2008, 04:28 PM
Hi,
i create my menu server-side (all with navigateurl).

I set my top level menu to be ClickToOpen=True, but i cant seem to make the top level menu close when i have selected a child menu.

It stays open and i have to click somewhere on the page to close it.

Is there any way (code or javascript) to close the top level menu when one of its child menus have been selected ??

Many Thanks
Mark

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 27 Nov 2008, 04:34 AM
Hi Mark,

You can use the following function to close the RadMenuitem on clicking on item. Call the function on "OnClientItemClicked" event of RadMenu.

JavaScript:
<script type="text/javascript">  
function OnClientItemClicked(sender, eventArgs)  
{  
    if (eventArgs.get_item().get_parent() !=  sender)  
    {  
        var text= eventArgs.get_item().get_parent().get_text();  
        var menu = $find("<%= RadMenu1.ClientID %>");  
        var item = menu.findItemByText(text);  
        if (item)  
        {  
            item.close();  
        }  
    }  
}  
</script> 

Thanks,
Princy.
0
Mark
Top achievements
Rank 1
answered on 27 Nov 2008, 10:49 AM
Hi,thanks for the reply.

However,
i am creating the menu items server-side.

for the child menus i use

childmenu.Attributes.Add("OnClick", "OnClientItemClicked()")

but this is not firing in the javascript

 

if

(eventArgs.get_item().get_parent() != sender)


What do i pass to the function ? (trued below but did'nt work )
childmenu.Attributes.Add("OnClick", "OnClientItemClicked(" & childmenu.ClientID & ")")

Any ideas please ?
Thanks
Mark

 

0
Veselin Vasilev
Telerik team
answered on 28 Nov 2008, 08:22 AM
Hi Mark,

To subscribe to the OnClientItemClicked client-side event you need to do it like this:

RadMenu1.OnClientItemClicked = "OnClientItemClickedHandler";


I could not reproduce the problem that you describe. Can you paste some relevant code here please?


Kind regards,
Veselin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Menu
Asked by
Mark
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Mark
Top achievements
Rank 1
Veselin Vasilev
Telerik team
Share this question
or