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

Open menu on click AND mouseover

9 Answers 546 Views
Menu
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 30 Jul 2010, 09:45 AM
Hi,

i know there is a setting ClickToOpen setting to allow you to choose BETWEEN the menu opening on a click, or when the mouse goes over it.

I however would like the menu to open  for BOTH a click and mouse over. th reason being that we have an intranet application that we are going to be sharing out onto the internet. Our main users will be using full IE and like the menu opening when the mouse overs. Our remote users will be using iphones and cannot use the mouse over, so the idea solution is to have both modes enabled.

Is this possible?

9 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 30 Jul 2010, 10:53 AM
Hello James,

Check out the following sample code which opens the RadMenu on menu click and on MouseOver.

ASPX:
<telerik:RadMenu ID="RadMenu1" OnClientMouseOut="OnClientMouseOut" OnClientMouseOver="MouseOver"
    runat="server" ClickToOpen="True">
   <Items>
     <telerik:RadMenuItem runat="server" Text="Root RadMenuItem1" Value="value1" >
         <Items>
            <telerik:RadMenuItem runat="server" Text="Child RadMenuItem 1" Value="value11" >
            </telerik:RadMenuItem>
            <telerik:RadMenuItem runat="server" Text="Child RadMenuItem 2" Value="value22">
            </telerik:RadMenuItem>
          </Items>
       </telerik:RadMenuItem>
    </Items>
</telerik:RadMenu>

Java Script:
<script type="text/javascript">
    function MouseOver(sender, args) {
        args.get_item().open();
    }
    function OnClientMouseOut(sender, args) {
        args.get_item().close();
    }
</script>

Thanks,
Princy.
0
James
Top achievements
Rank 1
answered on 30 Jul 2010, 11:03 AM
Brilliant, thanks!
0
James
Top achievements
Rank 1
answered on 30 Jul 2010, 11:05 AM
sorry - just noticed, this works mostly, but, if you mouse over a menu item it closes the menu (i guess the mouse out is firing?)

0
Ulrich
Top achievements
Rank 1
answered on 20 May 2011, 09:01 AM
I have the same problem here. I've been trying to get my menu open on both a click and mouse over. I thought I finally had the solution, but then I noticed the same problem as James, when I mouse over a (parent) menu item, the (child) item menu opens. However, when I now leave the parent item and move the mouse over to a child item, the menu closes again and I can't open any item...

See also my attached code below.

Is there any solution to this???

Any help would be appreciated!

<
telerik:RadMenu ID="RadMenu1" runat="server" Style="z-index: 2900" DataFieldID="ID" 
    DataFieldParentID="ParentID" DataTextField="Bezeichnung" Height="16px" Width="890px" 
    Font-Bold="True" Font-Size="Small" Font-Names="Arial" EnableRoundedCorners="True" 
    EnableShadows
="True" CollapseDelay="200" DataValueField="Link" ClickToOpen="True" 
    OnClientItemClicking
="OnClientItemClicking" OnClientMouseOver="MouseOver" 
    OnClientMouseOut="OnClientMouseOut"
<CollapseAnimation Type="InCubic" /> 
<ExpandAnimation Type="OutCubic" />
</telerik:RadMenu>
  
  
<script type="text/javascript">
        function OnClientItemClicking(sender, eventArgs) {
            var item = eventArgs.get_item();
  
            if (item.get_level() == 0) {
                item.open();
                eventArgs.set_cancel(true);
            }
            else {
                eventArgs.set_cancel(false);
            }
        }
  
        function MouseOver(sender, args) {
            args.get_item().open();
        }
        function OnClientMouseOut(sender, args) {
            args.get_item().close();
        }
    </script>
0
Kate
Telerik team
answered on 25 May 2011, 03:39 PM
Hi Ulrich,

I tested your code and I am not sure why you are using the MouseOver and the OnClientMouseOut client-side functions. Simply by using the OnClientItemClicking function and the ClickToOpen="false" property you can achieve the desired functionality of the RadMenu. Here is the markup of the RadMenu:

<telerik:RadMenu ID="RadMenu1" runat="server" Style="z-index: 2900" DataFieldID="ID"
    DataFieldParentID="ParentID" DataTextField="Bezeichnung" Height="16px" Width="890px"
    Font-Bold="True" Font-Size="Small" Font-Names="Arial" EnableRoundedCorners="True"
    EnableShadows="True" CollapseDelay="200" DataValueField="Link" OnClientItemClicking="OnClientItemClicking">
    <CollapseAnimation Type="InCubic" />
    <ExpandAnimation Type="OutCubic" />
   ...
</telerik:RadMenu>

Regards,
Kate
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
James
Top achievements
Rank 1
answered on 25 May 2011, 03:52 PM
specifically i wanted to have a rad menu that was usable on both trandtional desktop PCs where the user would just mouse over the AND ALSO on a touche screen phone, such as an iPhone where there is no mouse over events.

ont he iPhone, etc, you can detect the mouse over if they tap, but then you can't use the mousout to close the menu again - hence, wanting to open the menu if they tapped or mouse overed.

have you got a working solution to this?
0
Ulrich
Top achievements
Rank 1
answered on 27 May 2011, 09:13 AM
Hi Kate,

thanks so much for your solution, that was exactly what I was looking for!

Ulrich
0
Ivan Zhekov
Telerik team
answered on 27 May 2011, 10:49 AM
Hi James,

We tested on iPad and Galaxy S based devises, as well as a Windows 7 phone, and the snippet below worked. You may experience different smoothness of the animation, based on the device's specs, but otherwise the snippet works fine.

function OnClientItemClicking(sender, eventArgs) {
    var item = eventArgs.get_item();
 
    if (item.get_level() == 0) {
        item.open();
        eventArgs.set_cancel(true);
    }
    else {
        eventArgs.set_cancel(false);
    }
}

<telerik:RadMenu ID="RadMenu1" runat="server" ... OnClientItemClicking="OnClientItemClicking" ...>
...
</telerik:RadMenu>

The mouse events are not required, nor is the ClickToOpen attribute.

Greetings,
Ivan Zhekov
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Mark
Top achievements
Rank 1
answered on 17 Feb 2012, 03:51 AM
This thread has saved me some sleepless nights, that's for sure.   Thanks Ivan and Kate; Telerik support is awesome as usual.  Thanks to other posters for asking the question.
Tags
Menu
Asked by
James
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
James
Top achievements
Rank 1
Ulrich
Top achievements
Rank 1
Kate
Telerik team
Ivan Zhekov
Telerik team
Mark
Top achievements
Rank 1
Share this question
or