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

RadNavigation Object

The following table lists the most important of the RadNavigation object's client-side methods:

 

NameParametersReturn TypeDescription
get_enablednonebooleanTrue if the navigation is enabled.
set_enabledBooleannoneEnables/disables the navigation.
findNodeByText(string text)NavigationNodeReturns the first NavigationNode object whose Text property is equal to the passed parameter.
findNodeByUrl(string URL)NavigationNodeReturns the first NavigationNode object whose NavigateUrl property is equal to the passed parameter.
get_nodesnoneNavigationNodeCollectionReturns the collection of root level nodes. See Example 1.
get_allNodesnoneArrayGets a linear collection of all nodes. This includes all root and child nodes in the navigation. See Example 2.
focusnonenoneBrings the focus to the first Navigation node.
get_expandedNodenoneNavigationNodeReturns the expanded root level node. If no node is expanded at the root level returns null.
get_selectedNodenoneNavigationNodeReturns the selected Navigation node. If no node is selected returns null.
get_firstNodenoneNavigationNodeReturns the first Navigation node. If the Navigation does not contain nodes returns null.
get_elementnoneHTML ElementGets the DOM element for the Navigation (div). See Example 3.
get_childListElementnoneHTML ElementGets the DOM element for the list of nodes in the navigation (UL).
add_EventName(mixed eventHandler)noneAttaches an eventHandler to the event with the name <EventName>. See Example 4.
remove_EventName(mixed eventHandler)noneDetaches an eventHandler from the event with the name <EventName>. See Example 5.
expandMenuButtonnonenoneExpands the Navigation Menu Button, showing the nodes it contains in a dropdown. See Example 6.
collapseMenuButtonnonenoneCollapses the Navigation Menu Button, hiding the expanded nodes. See Example 7.
get_visiblenoneBooleanTrue if the navigation is visible, false otherwise.
set_visibleBooleannoneSets the Navigation's visibility.
set_minWidthintegernoneSets the screen width under which all nodes are hidden. See Controlling the Point of Collapsing All Nodes.

Example 1: Get a collection of the root level nodes.

JavaScript
var nav = $find("<%= RadNavigation1.ClientID %>");
var nodes = nav.get_nodes();		

Example 2: Get a linear collection of all nodes.

JavaScript
var nav = $find("<%= RadNavigation1.ClientID %>");
var allnodes = nav.get_allNodes()	

Example 3: Hide/show the Navigation.

JavaScript
// hide the Navigation
// note this change does not persist after a postback
function hideNavigation()
{  
	var nav = $find("<%= RadNavigation1.ClientID %>");
	nav.get_element().style.display = "none";
}

// show the Navigation
function showNavigation()
{  
    var nav = $find("<%= RadNavigation1.ClientID %>"); 
	nav.get_element().style.display = "";
}		

Example 4: Attach an OnClientNodeClicked event handler.

JavaScript
function OnClientNodeClicked(sender, args) {
    alert("clicked");
}

function AttachClickHandler()
{   
    var nav = $find("<%= RadNavigation1.ClientID %>"); 
	nav.add_nodeClicked(OnClientNodeClicked);
}		

Example 5: Remove the OnClientNodeClicked handler.

JavaScript
function OnClientNodeClicked(sender, args) {
    alert("clicked");
}

function RemoveClickHandler()
{   
    var nav = $find("<%= RadNavigation1.ClientID %>"); 
	nav.remove_nodeClicked(OnClientNodeClicked);
}		

Example 6: Expand the Navigation Menu Button.

JavaScript
function ExpandMenuButton()
{   
    var nav = $find("<%= RadNavigation1.ClientID %>"); 
	nav.expandMenuButton();
}		

Example 7: Collapse the Navigation Menu Button.

JavaScript
function CollapseMenuButton()
{   
    var nav = $find("<%= RadNavigation1.ClientID %>"); 
	nav.collapseMenuButton();
}		

See Also

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