r.a.d.menu provides a flexible client-side API - you can
easily interact with the menu in the browser using the menu
client-side object.
-
Getting the RadMenu client-side object: RadMenu creates a client-side object
with the ClientID of the menu. You can obtain the reference using the following
javascript code:
var menu = <%= RadMenu1.ClientID %>;
-
Once you get the client-side object of RadMenu, you can use the FindItemByText
methods to get the instance of a particular item. Example:
var menu = <%= RadMenu1.ClientID %>;
var item = menu.FindItemByText(text);
When you get the instance of a particular item, you can iterate through
hierarchy and open all the parents and the item itself.
function ExpandItemByText(text)
{
var menu = <%= RadMenu1.ClientID %>;
var item = menu.FindItemByText(text);
if (!item)
{
alert("Item with text '" + text + "' not found.");
return;
}
// override the initial focus executed by the browser on load
setTimeout(function () { item.Focus(); }, 0);
}