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

Close radmenu item on click

9 Answers 232 Views
Menu
This is a migrated thread and some comments may be shown as answers.
L.K. T.
Top achievements
Rank 1
L.K. T. asked on 07 Dec 2009, 05:59 PM
Hi,

I have a radmenu with items that target a iframe inside the page. I like the menu to close immediately after it has been clicked. How can i do that? I think this should be a feature of the menu itself. But it seems it's not possible to do this easily without a lot of javascripts. Can you please show me how to do this?

Thanks in advance.

9 Answers, 1 is accepted

Sort by
0
Schlurk
Top achievements
Rank 2
answered on 07 Dec 2009, 08:52 PM
If you subscribe to OnClientItemClickedand use the following javascript I think it'll work:

            function onClicked(sender, eventArgs) { 
                var menu = $find("<%= RadMenu1.ClientID %>"); 
                menu.close(); 
            }  

0
L.K. T.
Top achievements
Rank 1
answered on 08 Dec 2009, 09:26 AM
function  RadMenuCloseOnClicked(sender, args)   
{  
sender.close();  
}  
 
 

 


I have registered the OnClientItemClicked of the menu to the javascript function. It seems to achieve what i want. But I still think the menu should include a property to achieve this without the need to write any javascript. This is how a menu standard behaves. It will close when you click on it.
0
David
Top achievements
Rank 1
answered on 29 Dec 2016, 08:55 PM

I know this is an old thread, but menu.close() used to work in previous version of Telerik. For some reason it stoped working and collapsing the menu.

<telerik:RadMenu ID="rad_menu" runat="server" EnableRoundedCorners="true" DataFieldID="id" DataFieldParentID="parentID"

EnableEmbeddedSkins="false" Skin="CetTelerikSkin" ExpandAnimation-Duration="0" ExpandAnimation-Type="None" CollapseAnimation-Type="None" CausesValidation="False" ClickToOpen="false" ExpandDelay="500" CollapseDelay="1500"                                                        

OnClientItemClicked="OnMenuClientItemClicked"

EnableRootItemScroll="true" Width="100%">

<DefaultGroupSettings ExpandDirection="Auto" OffsetY="2" />

 

 

 

</telerik:RadMenu>

<script type="text/javascript">

function OnMenuclientItemClicked(sender, args){

sender.close();

}

</script>

Any thoughts on why it stopped to work, and if there is a workaround for this?

 

 

 

0
Plamen
Telerik team
answered on 02 Jan 2017, 05:53 AM
Hi,

Thank you for sharing the issue.

Yes indeed -due to a major change that we had to push in the control we recommend using setTimeout when invoking the close function from the click event of the control:
setTimeout(function() {
             sender.close();
         }, 0);


Regards,
Plamen
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
David
Top achievements
Rank 1
answered on 03 Jan 2017, 05:48 PM
Thank you Plamen, It works.
0
Mark
Top achievements
Rank 1
answered on 23 Mar 2018, 04:57 PM

So the setTimeout seems to work except when render mode is using Mobile from a phone.  I have set rendermode="Mobile" and it seems to work from my desktop but when I use my iphone, it will collapse the menu, but it doesn't seem to execute the NavigateUrl into my target.

 

Any ideas?

0
Vessy
Telerik team
answered on 28 Mar 2018, 11:48 AM
Hi Mark,

Did you try increasing the timeout value passed to the close() method?
setTimeout(function() {
     sender.close();
}, 100);

You can also test if removing the timeout at all will help (in this way the browser will add this task to the end of the current queue):
setTimeout(function() {
    sender.close();
});


Regards,
Vessy
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Mark
Top achievements
Rank 1
answered on 28 Mar 2018, 12:04 PM

Yes, that looks to have fixed the issue.

 

Thanks!

[quote]Vessy said:Hi Mark,

Did you try increasing the timeout value passed to the close() method?

setTimeout(function() {
     sender.close();
}, 100);

You can also test if removing the timeout at all will help (in this way the browser will add this task to the end of the current queue):
setTimeout(function() {
    sender.close();
}, 0);


Regards,
Vessy
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
[/quote]
0
Vessy
Telerik team
answered on 28 Mar 2018, 01:41 PM
Hi,

You are welcome, Mark - I am glad the suggested solution is working for you.

Regards,
Vessy
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Menu
Asked by
L.K. T.
Top achievements
Rank 1
Answers by
Schlurk
Top achievements
Rank 2
L.K. T.
Top achievements
Rank 1
David
Top achievements
Rank 1
Plamen
Telerik team
Mark
Top achievements
Rank 1
Vessy
Telerik team
Share this question
or