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

[Solved] Keep menu item open

2 Answers 130 Views
Menu
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Donna Stewart
Top achievements
Rank 1
Donna Stewart asked on 25 Aug 2011, 05:17 PM
I am using the mvc extension menu with the content method to one item in which I have a dropdownlist and a search field with a link following.  When I try to select something from the dropdown, the menu item closes.  I have tried creating onOpen and onClose functions using stopPropagation to keep the menu item open until the link is clicked.  However, this is not working.  Is this possible or is there something I am missing?  Thank you so much for your help!
Here is the code:
<%@ Control Language="VB" Inherits="System.Web.Mvc.ViewUserControl(Of GMC_Hub_and_Spoke.WQIndexViewModel)" %>
<%@ Import Namespace="GMC_Hub_And_Spoke" %>
<%@ Import Namespace="com.gmcps" %>
<script type="text/javascript">
    $(document).ready(function () {
        $('a#submit_link').click(function () {
            var menu = $("#OLODReportsMenu").data("tMenu");
            menu.close($(".t-item", menu.element)[1]);          
            var specificUrl;
            var urlFormat;
            urlFormat = '<%= HttpUtility.UrlDecode(Url.Action("FindOLODReport", "WebQuery", New With { .stringToFind = "{0}", .searchType = "{1}"})) %>';
            specificUrl = $.telerik.formatString(urlFormat, $("#stringToFind").val(), $("sType").val());
            $("#webquerylist").load(specificUrl);
        });
    });
 
    function onOpen(e) {
        e.stopPropagation();
        var menu = $("#OLODReportsMenu").data("tMenu");
        menu.open($(e.item));
    }
 
    function onClose(e) {
        alert("in onClose");
        e.stopPropagation();
    }
 
</script>
<div>
    <div id="queryindexleft">
        <span class="listbox-label">Online/OnDemand Reports</span><br />
        <% Html().Telerik().Menu.Name("OLODReportsMenu").Orientation(Telerik.Web.Mvc.UI.MenuOrientation.Vertical).HtmlAttributes(New With {.style = "width:300px;"}) _
               .ClientEvents(Function(events) events.OnOpen("onOpen")).ClientEvents(Function(events) events.OnClose("onClose")) _
            .Items(Function(item) item.Add.Text("Add New Online/On Demand Report").Action("AddNew", "WebQuery")) _
            .Items(Function(item) item.Add.Text("Find Online/On Demand Report") _
                       .Content(Sub()%>
                            <div style="width:350px; height:60px;">
                                <%: Html.DropDownList("sType", Model.searchType, "--Select--")%>
                                <%: Html.Label("Search ")%>
                                <%: Html.TextBox("stringToFind")%>
                                <a href="#" id="submit_link">Go</a>
                            </div>
                <%End Sub)).Render()%>
        <br />
        <span id="webquerylist"></span>
    </div>
    <div id="queryindexright"></div>
</div>

Donna

2 Answers, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 26 Aug 2011, 07:23 AM
Hello Donna Stewart,

 Menu items close when the user moves the mouse of them, or when the user clicks them. You can change this behavior by enabling OpenOnClick:

<% Html.Telerik().Menu()
            .Name("Menu")
            .OpenOnClick(true)

Regards,
Atanas Korchev
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Donna Stewart
Top achievements
Rank 1
answered on 26 Aug 2011, 04:11 PM
This works.  Thank you!  I didn't see a reference to that in my forum searches or in the documentation.  Thank you again for your help!
Donna

Edit: I did find it in the online documentation under Menu -> Server API.  Sorry and thanks!
Tags
Menu
Asked by
Donna Stewart
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Donna Stewart
Top achievements
Rank 1
Share this question
or