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

Disable Radmenu item

4 Answers 95 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Ben
Top achievements
Rank 1
Ben asked on 04 Mar 2013, 01:57 PM
Hi,

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

Thank you,
Ben.

4 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 1
answered on 04 Mar 2013, 02:09 PM
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.
0
Ben
Top achievements
Rank 1
answered on 05 Mar 2013, 11:37 AM
Thanks princy. Also can u show how to add an image to the disabled menu item.
0
Accepted
Princy
Top achievements
Rank 1
answered on 05 Mar 2013, 11:43 AM
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
0
Ben
Top achievements
Rank 1
answered on 05 Mar 2013, 12:52 PM
Thanks for your instant reply. It works fine.
Tags
Menu
Asked by
Ben
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Ben
Top achievements
Rank 1
Share this question
or