Disable Radmenu item

5 posts, 2 answers
  1. Ben
    Ben avatar
    31 posts
    Member since:
    Feb 2013

    Posted 04 Mar 2013 Link to this post

    Hi,

    How to disable a radmenu item based on the RadListBox Item checked state?

    Thank you,
    Ben.
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 04 Mar 2013 Link to this post

    Hi Ben,

    Please have a look at the following code I tried to disable a menu item based on the RadListBox item checked state.

    ASPX:
    <telerik:RadMenu ID="RadMenu1" runat="server">
        <Items>
            <telerik:RadMenuItem runat="server" Text="Menu Item1">
                <Items>
                    <telerik:RadMenuItem runat="server" Text="Item11">
                    </telerik:RadMenuItem>
                </Items>
            </telerik:RadMenuItem>
            <telerik:RadMenuItem runat="server" Text="Menu Item1">
            </telerik:RadMenuItem>
        </Items>
    </telerik:RadMenu>
    <br />
    <br />
    <telerik:RadListBox ID="RadListBox1" runat="server" CheckBoxes="true" OnClientItemChecked="OnClientItemChecked"
        Width="200px">
        <Items>
            <telerik:RadListBoxItem runat="server" Text="Disable Item11" />
        </Items>
    </telerik:RadListBox>

    JavaScript:
    <script type="text/javascript">
        function OnClientItemChecked(sender, args) {
            var menu = $find("<%= RadMenu1.ClientID %>");
            var menuItem = menu.findItemByText("Item11");
            if (sender.findItemByText("Disable Item11").get_checked() == true) {
                menuItem.disable();
            }
            else {
                menuItem.enable();
            }
        }
    </script>

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ben
    Ben avatar
    31 posts
    Member since:
    Feb 2013

    Posted 05 Mar 2013 Link to this post

    Thanks princy. Also can u show how to add an image to the disabled menu item.
  5. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 05 Mar 2013 Link to this post

    Hello Ben,

    Inside the JavaScript if condition you can set the menu item image using the set_imageUrl method. Please check the following code.

    JavaScript:
    if (sender.findItemByText("Disable Item11").get_checked() == true) {
                menuItem.disable();
                menuItem.set_imageUrl("../Images/YourImage.jpg");
            }

    Thanks,
    Princy
  6. Ben
    Ben avatar
    31 posts
    Member since:
    Feb 2013

    Posted 05 Mar 2013 Link to this post

    Thanks for your instant reply. It works fine.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017