RadMenu ClickToOpen="true" does not work when using ItemTemplate

2 posts, 0 answers
  1. Gavin
    Gavin avatar
    1 posts
    Member since:
    Apr 2016

    Posted 11 Apr Link to this post

    I need to use the following ItemTemplate for styling reasons, however ClickToOpen="true" does not work. What needs to be added in order for ClickToOpen to work properly? If I remove the ItemTemplate block it works as expected.

    <telerik:RadMenu ID="RadMenu1" runat="server" ClickToOpen="true" Skin="Bootstrap">
        <Items>
            <telerik:RadMenuItem Text="Item 1">
                <ItemTemplate>
                    <div class="caption">
                        <a href="#"><span><i></i>Item 1</span></a>
                    </div>
                </ItemTemplate>
                <Items>
                    <telerik:RadMenuItem Text="Sub Item 1"></telerik:RadMenuItem>
                    <telerik:RadMenuItem Text="Sub Item 2"></telerik:RadMenuItem>
                    <telerik:RadMenuItem Text="Sub Item 3">
                        <Items>
                            <telerik:RadMenuItem Text="Sub Sub Item 1"></telerik:RadMenuItem>
                            <telerik:RadMenuItem Text="Sub Sub Item 2"></telerik:RadMenuItem>
                            <telerik:RadMenuItem Text="Sub Sub Item 3"></telerik:RadMenuItem>
                        </Items>
                    </telerik:RadMenuItem>
                </Items>
            </telerik:RadMenuItem>
            <telerik:RadMenuItem Text="Item 2">
                <ItemTemplate>
                    <div class="caption">
                        <a href="#"><span><i></i>Item 2</span></a>
                    </div>
                </ItemTemplate>
                <Items>
                    <telerik:RadMenuItem Text="Sub Item 1"></telerik:RadMenuItem>
                    <telerik:RadMenuItem Text="Sub Item 2"></telerik:RadMenuItem>
                    <telerik:RadMenuItem Text="Sub Item 3">
                        <Items>
                            <telerik:RadMenuItem Text="Sub Sub Item 1"></telerik:RadMenuItem>
                            <telerik:RadMenuItem Text="Sub Sub Item 2"></telerik:RadMenuItem>
                            <telerik:RadMenuItem Text="Sub Sub Item 3"></telerik:RadMenuItem>
                        </Items>
                    </telerik:RadMenuItem>
                </Items>
            </telerik:RadMenuItem>
        </Items>
    </telerik:RadMenu>

  2. Veselin Tsvetanov
    Admin
    Veselin Tsvetanov avatar
    290 posts

    Posted 14 Apr Link to this post

    Hello Gavin,

    The problem in your scenario is the fact that you have an <a> tag within your ItemTemplate that reloads the page. It actually gets fired before the sub-menu is opened. Removing the <a> tag should solve the issue for you.

    Regards,
    Veselin Tsvetanov
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top