New to Telerik UI for ASP.NET AJAXStart a free 30-day trial

RadMenuItem Object

The RadMenuItem object is returned by the getItem method of the RadMenuItemCollection object. It is also exposed by the eventArgs of many client-side events. The following table lists the most important methods:

NameParametersReturn TypeDescription
disablenonenoneDisables the item. See Example 1.
enablenonenoneEnables the item if it is disabled. See Example 2.
get_isEnablednoneBooleanReturns true if both the item and the menu are enabled. If one of them is disabled, get_isEnabled() will return false.
get_enablednoneBooleanSame as get_isEnabled.
set_enabledBooleannoneSets the enabled state of the item.
focusnonenoneMoves focus to the item. See Example 3.
blurnonenoneRemoves focus from the item. See Example 4.
focusPreviousItemnonenoneMoves focus to the previous item.
focusNextItemnonenoneMoves focus to the next item.
focusFirstChildnonenoneMoves focus to the first child of the item.
focusLastChildnonenoneMoves focus to the last child of the item.
get_focusedItemnoneRadMenuItemGets the focused child item. Null if no child item is focused.
get_focusednoneBooleanIndicates whether the menu item is focused.
set_focusednonenoneSets focus to the item.
get_itemsnoneRadMenuItemCollectionGets the child items of the current item.
get_nextItemnoneRadMenuItemReturns the next sibling of the item. If the item is last, returns null.
get_previousItemnoneRadMenuItemReturns the previous sibling of the item. If the item is first, returns null.
get_openedItemnoneRadMenuItemGets the opened child item. Null if no child item is opened.
get_parentnoneRadMenu, RadContextMenu or RadMenuItemReturns an instance of the parent object. RadMenu or RadContextMenu if this is a root item, RadMenuItem if it is a child item.
get_menunoneRadMenu or RadContextMenuReturns an instance of the menu that contains the item.
get_indexnoneIntegerGets the zero based index of the item inside the parent items collection.
get_levelnoneIntegerGets the level of the item. Root level items are first level.
get_attributes(none)CollectionReturns the collection of custom attributes for the item. See Example 5.
opennonenoneExpands the item and reveals its children, if any.
closenonenoneCollapses the item, if it is expanded.
clicknonenonePerforms a click on the menu item. It can cause postback, but it will not redirect to another page. See this example.
get_visiblenonebooleanReturns true if the items is visible or false if the item is invisible.
set_visiblebooleannoneSets the visibility of the item
shownonenoneShows the item if it was set invisible on the client. The same as set_visible(true)
hidenonenoneHides the item. The same as set_visible(false)
set_textstring textnoneSets the text of the item.
get_textnonestring textReturns the text of the item.
set_valuestring valuenoneSets the Value property of the item.
get_valuenonestring valueReturns the Value property of the item.
get_isSeparatornonebooleanReturns true the item is a separator (sever-side property IsSeparator = true)
get_navigateUrlnonestringGets the URL of the Web page the menu item launches.
set_navigateUrlstringnoneSets the navigateURL property of the item. This is the URL of the Web page the menu item launches and it must be an absolute URL on the client side: e.g., http://mydomain.com/default.aspx not default.aspx. See Example 6.
set_imageUrl(string imageUrl)noneSets the URL of the image.
get_imageUrlnone(string imageUrl)Gets the URL of the image.
set_hoveredImageUrl(string imageUrl)noneSets the URL of the image displayed when the mouse is over the item.
get_hoveredImageUrlnone(string imageUrl)Gets the URL of the image displayed when the mouse is over the item.
get_elementnoneHTML ElementGets the root DOM element of the item (LI).
get_linkElementnoneHTML ElementGets the anchor DOM element of the item (A).
get_imageElementnoneHTML ElementGets the image DOM element of the item. If the server side ImageUrl property is not set,returns null.
get_textElementnoneHTML ElementGets the DOM element of the item text (SPAN).
get_childListElementnoneHTML ElementGets the DOM element of the list of child items (UL).
findControlstringobjectReturns the object nested in the item's template
get_selectednoneBooleanReturns whether the item is selected
set_selectedBooleannoneSets the selected property of the item.
get_selectedImageUrlnone(string imageURL)Gets the value of the SelectedImageUrl property
set_selectedImageUrlstring (imageUrl)noneSets the URL of the image displayed when the item is selected

Example 1: Disable the item.

JavaScript
var menu = $find("<%= RadMenu1.ClientID %>");
var menuItem = menu.findItemByText("Paris");
menuItem.disable();			

Example 2: Enable the item.

JavaScript
var menu = $find("<%= RadMenu1.ClientID %>");
var menuItem = menu.findItemByText("Paris");
menuItem.enable();		

Example 3: Focus the item.

JavaScript
var menu = $find("<%= RadMenu1.ClientID %>");
var menuItem = menu.findItemByText("Paris");
menuItem.focus();	

Example 4: Blur the item.

JavaScript
var menu = $find("<%= RadMenu1.ClientID %>");
var menuItem = menu.findItemByText("Paris");
menuItem.blur();

Example 5: Get and set the item's custom attributes.

JavaScript
var menu = $find("<%= RadMenu1.ClientID %>");
var foundItem = menu.findItemByAttribute("Population", "0");
var attributes = foundItem.get_attributes();
var size = attributes.getAttribute("size");
if (size) {
    attributes.setAttribute("Population", size);
    attributes.removeAttribute("size");
}
else {
    attributes.setAttribute("Population", "Unknown");
}			

See Also

In this article
See Also
Not finding the help you need?
Contact Support