New to Telerik UI for ASP.NET AJAX? Start a free 30-day trial

The RadTreeView control is used to display a list of nodes in a Web Forms page. The RadTreeView control supports the following features:

  • Danodeinding that allows the control to be populated from various datasources.
  • Programmatic access to the RadTreeView object model which allows dynamic creation of treeviews, populating with nodes and customizing the behavior by various properties.
  • Customizable appearance through built-in or user-defined skins.

nodes

The RadTreeView control is made up of tree of nodes represented by RadTreeNode objects. Nodes at the top level (level 0) are called root nodes. An node that has a parent node is called a child node. All root nodes are stored in the Nodes property of the RadTreeView control. Child nodes are stored in the Nodes property of their parent RadTreeNode.

Each node has a Text and a Value property. The value of the Text property is displayed in the RadTreeView control, while the Value property is used to store any additional data about the node, such as data passed to the postback event associated with the node. When clicked, a node can navigate to another Web page indicated by the NavigateUrl property.

Definition

Namespace:Telerik.Web.UI

Assembly:Telerik.Web.UI.dll

Syntax:

C#
[EmbeddedSkin("TreeView", typeof(RadTreeView))]
[EmbeddedSkin("TreeView", "Default", typeof(RadTreeView))]
[RequiredCss("Telerik.Web.UI.Skins.Common.fonticons.css", RenderMode.Lightweight, typeof(RadTreeView))]
[RequiredCss("Telerik.Web.UI.Skins.Common.MaterialRipple.css", RenderMode.Lightweight, typeof(RadButton))]
[RequiredScript(typeof(jQueryPlugins))]
[RequiredScript(typeof(OData))]
[RequiredScript(typeof(TouchScrollExtender))]
[RequiredScript(typeof(MaterialRipple))]
[ClientScriptResource("Telerik.Web.UI.RadTreeView", "Telerik.Web.UI.TreeView.RadTreeViewScripts.js")]
[TelerikToolboxCategory("Navigation")]
[ToolboxBitmap(typeof(RadTreeView), "Toolbox.Icons.TreeView.png")]
[ControlValueProperty("SelectedValue")]
[ValidationProperty("SelectedValue")]
public class RadTreeView : HierarchicalControlItemContainer, IComponent, IDisposable, IParserAccessor, IUrlResolutionService, IDataBindingsAccessor, IControlBuilderAccessor, IControlDesignerAccessor, IExpressionsAccessor, IAttributeAccessor, IScriptControl, IControlResolver, IPostBackDataHandler, ISkinnableControl, IControl, IFeatureGroup, INamingContainer, IXmlSerializable, IControlItemContainer, IRadTreeNodeContainer, IPostBackEventHandler, ICallbackEventHandler

Inheritance: objectControlWebControlBaseDataBoundControlDataBoundControlRadDataBoundControlControlItemContainerHierarchicalControlItemContainerRadTreeView...

Implements: IAttributeAccessorICallbackEventHandlerIComponentIControlIControlBuilderAccessorIControlDesignerAccessorIControlItemContainerIControlResolverIDataBindingsAccessorIDisposableIExpressionsAccessorIFeatureGroupINamingContainerIParserAccessorIPostBackDataHandlerIPostBackEventHandlerIRadTreeNodeContainerIScriptControlISkinnableControlIUrlResolutionServiceIXmlSerializable...

Inherited Members HierarchicalControlItemContainer.GetDataSource()HierarchicalControlItemContainer.PerformDataBinding(IEnumerable)HierarchicalControlItemContainer.FindChildByUrl<TControlItem>(string)HierarchicalControlItemContainer.FindItemByHierarchicalIndex(string)HierarchicalControlItemContainer.DataNavigateUrlFieldHierarchicalControlItemContainer.DataFieldIDHierarchicalControlItemContainer.DataFieldParentIDControlItemContainer.PrepareForDataBinding()ControlItemContainer.GetXml()ControlItemContainer.LoadXml(string)ControlItemContainer.CreateItem(ClientStateLogEntry)ControlItemContainer.FindChild<TControlItem>(Predicate<TControlItem>)ControlItemContainer.GetAllChildren<TControlItem>()ControlItemContainer.FindChildByValue<TControlItem>(string)ControlItemContainer.FindChildByValue<TControlItem>(string, bool)ControlItemContainer.FindChildByText<TControlItem>(string)ControlItemContainer.FindChildByText<TControlItem>(string, bool)ControlItemContainer.FindChildByAttribute<TControlItem>(string, string)ControlItemContainer.InitializeItem(ControlItem)ControlItemContainer.ReadXml(XmlReader)ControlItemContainer.GetItemTypeFromXmlTagName(string)ControlItemContainer.ReadXmlForChildren(XmlReader)ControlItemContainer.WriteXml(XmlWriter)ControlItemContainer.WriteXmlForChildren(XmlWriter)ControlItemContainer.GetXml(XmlSerializer, TextWriter)ControlItemContainer.LoadXml(ControlItemContainer)ControlItemContainer.GetPostbackEventReference()ControlItemContainer.AppendDataBoundItemsControlItemContainer.DataTextFieldControlItemContainer.DataValueFieldControlItemContainer.DataTextFormatStringControlItemContainer.ValidationGroupControlItemContainer.CausesValidationControlItemContainer.KeyboardNavigationSettingsControlItemContainer.TemplateControlItemContainer.ChildrenControlItemContainer.TagKeyDataBoundControl.OnCreatingModelDataSource(CreatingModelDataSourceEventArgs)DataBoundControl.CreateDataSourceSelectArguments()DataBoundControl.GetData()DataBoundControl.MarkAsDataBound()DataBoundControl.OnDataPropertyChanged()DataBoundControl.OnDataSourceViewChanged(object, EventArgs)DataBoundControl.OnLoad(EventArgs)DataBoundControl.OnPagePreLoad(object, EventArgs)DataBoundControl.PerformSelect()DataBoundControl.ValidateDataSource(object)DataBoundControl.DataMemberDataBoundControl.IsUsingModelBindersDataBoundControl.ItemTypeDataBoundControl.SelectMethodDataBoundControl.DataSourceIDDataBoundControl.DataSourceObjectDataBoundControl.SelectArgumentsDataBoundControl.CreatingModelDataSourceDataBoundControl.CallingDataMethodsBaseDataBoundControl.ConfirmInitState()BaseDataBoundControl.DataBind()BaseDataBoundControl.EnsureDataBound()BaseDataBoundControl.OnDataBound(EventArgs)BaseDataBoundControl.OnInit(EventArgs)BaseDataBoundControl.DataSourceBaseDataBoundControl.InitializedBaseDataBoundControl.IsBoundUsingDataSourceIDBaseDataBoundControl.IsDataBindingAutomaticBaseDataBoundControl.SupportsDisabledAttributeBaseDataBoundControl.RequiresDataBindingBaseDataBoundControl.DataBoundWebControl.ApplyStyle(Style)WebControl.CopyBaseAttributes(WebControl)WebControl.CreateControlStyle()WebControl.MergeStyle(Style)WebControl.Render(HtmlTextWriter)WebControl.RenderBeginTag(HtmlTextWriter)WebControl.RenderEndTag(HtmlTextWriter)WebControl.AccessKeyWebControl.AttributesWebControl.BackColorWebControl.BorderColorWebControl.BorderWidthWebControl.BorderStyleWebControl.ControlStyleWebControl.ControlStyleCreatedWebControl.CssClassWebControl.DisabledCssClassWebControl.StyleWebControl.EnabledWebControl.EnableThemingWebControl.FontWebControl.ForeColorWebControl.HasAttributesWebControl.HeightWebControl.IsEnabledWebControl.SkinIDWebControl.TabIndexWebControl.TagNameWebControl.ToolTipWebControl.WidthControl.ResolveAdapter()Control.HasEvents()Control.GetRouteUrl(object)Control.GetRouteUrl(string, object)Control.GetRouteUrl(RouteValueDictionary)Control.GetRouteUrl(string, RouteValueDictionary)Control.GetUniqueIDRelativeTo(Control)Control.ApplyStyleSheetSkin(Page)Control.OnDataBinding(EventArgs)Control.DataBind(bool)Control.DataBindChildren()Control.AddParsedSubObject(object)Control.EnsureID()Control.ClearChildState()Control.ClearChildControlState()Control.ClearChildViewState()Control.ClearEffectiveClientIDMode()Control.ClearCachedClientID()Control.Focus()Control.LoadControlState(object)Control.MapPathSecure(string)Control.OpenFile(string)Control.BuildProfileTree(string, bool)Control.SaveControlState()Control.RenderChildren(HtmlTextWriter)Control.RenderControl(HtmlTextWriter)Control.RenderControl(HtmlTextWriter, ControlAdapter)Control.OnUnload(EventArgs)Control.Dispose()Control.RaiseBubbleEvent(object, EventArgs)Control.OnBubbleEvent(object, EventArgs)Control.AddedControl(Control, int)Control.CreateControlCollection()Control.CreateChildControls()Control.ResolveUrl(string)Control.ResolveClientUrl(string)Control.FindControl(string)Control.FindControl(string, int)Control.GetDesignModeState()Control.HasControls()Control.IsLiteralContent()Control.EnsureChildControls()Control.RemovedControl(Control)Control.SetDesignModeState(IDictionary)Control.SetRenderMethodDelegate(RenderMethod)Control.ClientIDModeControl.ClientIDControl.ClientIDSeparatorControl.ContextControl.AdapterControl.DesignModeControl.EventsControl.IDControl.IsChildControlStateClearedControl.EnableViewStateControl.ViewStateModeControl.IsViewStateEnabledControl.NamingContainerControl.IdSeparatorControl.LoadViewStateByIDControl.PageControl.RenderingCompatibilityControl.TemplateControlControl.ParentControl.TemplateSourceDirectoryControl.AppRelativeTemplateSourceDirectoryControl.SiteControl.VisibleControl.HasChildViewStateControl.ControlsControl.ValidateRequestModeControl.ViewStateControl.ViewStateIgnoresCaseControl.ChildControlsCreatedControl.IsTrackingViewStateControl.DisposedControl.DataBindingControl.InitControl.LoadControl.PreRenderControl.Unloadobject.ToString()object.Equals(object)object.Equals(object, object)object.ReferenceEquals(object, object)object.GetHashCode()object.GetType()object.MemberwiseClone()...

Constructors

Initializes a new instance of the RadTreeView class.

C#
public RadTreeView()

Use this constructor to create and initialize a new instance of the RadTreeView control.

Example:
cs-api-definition
void Page_Load(object sender, EventArgs e)
{
RadTreeView RadTreeView1 = new RadTreeView();
RadTreeView1.ID = "RadTreeView1";

if (!Page.IsPostBack)
{
//RadTreeView persist its nodes in ViewState (if EnableViewState is true).
//Hence nodes should be created only on initial load.

RadTreeNode sportNode = new RadTreeNode("Sport");
RadTreeView1.Nodes.Add(sportNode);

RadTreeNode newsNode = new RadTreeNode("News");
RadTreeView1.Nodes.Add(newsNode);
}

PlaceHolder1.Controls.Add(RadTreeView1);
}

Properties

Gets a value indicating whether the text of the tree nodes are edinodele in the browser.

C#
[ClientControlProperty]
[ClientPropertyName("allowNodeEditing")]
public bool AllowNodeEditing { get; set; }

End-users can edit the text of tree-nodes by pressing F2 when the node is selected or by clicking on a node that is already selected (slow double click).

You can disable / enable node editing for specific tree nodes by setting the AllowEdit property of the specific RadTreeNode.


After node editing, RadTreeView fires the NodeEdit event and you can change the text of the node - the RadTreeNode instance is contained in the NodeEdited property of the event arguments and the new text is in the NewText property of the event arguments.
Example:
cs-api-definition
&lt;radT:RadTreeView
ID="RadTree1"
Runat="server"
AllowNodeEditing="True"
OnNodeEdit="HandleNodeEdit"
/&gt;

Protected Sub HandleNodeEdit(ByVal sender As Object, ByVal NodeEvents As RadTreeNodeEventArgs)
Dim nodeEdited As RadTreeNode = NodeEvents.NodeEdited
Dim newText As String = NodeEvents.NewText

nodeEdited.Text = newText
End Sub

When set to true displays a checkbox next to each treenode.

C#
[ClientControlProperty]
[ClientPropertyName("_checkBoxes")]
public bool CheckBoxes { get; set; }

Gets or sets a value indicating whether checking (unchecking) a node will check (uncheck) its child nodes.

C#
[ClientControlProperty]
[ClientPropertyName("_checkChildNodes")]
public bool CheckChildNodes { get; set; }
Property Value:

true if child nodes will be checked (checked) when the user checks (unchecks) their parent node; otherwise, false. The default value is false

Gets a collection of RadTreeNode objects that represent the nodes in the control that display a selected check box.

C#
[Browsable(false)]
public IList<RadTreeNode> CheckedNodes { get; }
Property Value:

An IList<RadTreeNode> containing the checked nodes.

When check boxes are displayed in the RadTreeView control (by setting the CheckBoxes property to true), use the CheckedNodes property to determine which nodes display a selected check box. This collection is commonly used to iterate through all the nodes that have a selected check box in the tree.

The CheckedNodes collection is populated using a depth-first traversal of the tree structure: each parent node is processed down to its child nodes before the next parent node is populated.

Example:
cs-api-definition
Protected Sub ShowCheckedNodes(ByVal sender As Object, ByVal e As System.EventArgs)
Dim message As String = String.Empty
Dim node As RadTreeNode
For Each node In RadTree1.CheckedNodes
message += node.FullPath
Next node
nodes.Text = message
End Sub

Gets a list of all client-side changes (adding a node, removing a node, changing a node's property) which have occurred.

C#
[Browsable(false)]
public IList<ClientOperation<RadTreeNode>> ClientChanges { get; }
Property Value:

A list of ClientOperation<T> objects which represent all client-side changes the user has performed. By default the ClientChanges property returns empty list. Client-changes are recorded if and only if the client-side methods trackChanges()/commitChanges() have been invoked.

You can use the ClientChanges property to respond to client-side modifications such as

  • adding a new item
  • removing existing item
  • clearing the children of an item or the control itself
  • changing a property of the item

The ClientChanges property is available in the first postback (ajax) request after the client-side modifications have taken place. After this moment the property will return empty list.

Example:
cs-api-definition
foreach (ClientOperation&lt;RadTreeNode&gt; operation in RadTreeView1.ClientChanges)
{
RadTreeNode node = operation.Item;

switch (operation.Type)
{
case ClientOperationType.Insert:
//A node has been inserted - operation.Item contains the inserted node
break;
case ClientOperationType.Remove:
//A node has been inserted - operation.Item contains the removed node.
//Keep in mind the node has been removed from the treeview.
break;
case ClientOperationType.Update:
UpdateClientOperation&lt;RadTreeNode&gt; update = operation as UpdateClientOperation&lt;RadTreeNode&gt;
//The "UpdateOperation" provides an additional property "PropertyName". This is the property whose value was changed from the client side.
break;
case ClientOperationType.Clear:
//All children of have been removed - operation.Item contains the parent node whose children have been removed. If operation.Item is null then the root nodes have been removed.
break;
}
}

Gets or sets the HTML template of a RadTreeNode when added on the client.

C#
[PersistenceMode(PersistenceMode.InnerProperty)]
[Browsable(false)]
public virtual string ClientNodeTemplate { get; set; }

Gets the settings for the animation played when a node closes.

C#
[PersistenceMode(PersistenceMode.InnerProperty)]
public AnimationSettings CollapseAnimation { get; }
Property Value:

An AnimationSettings that represents the collapse animation.

Use the CollapseAnimation property to customize the expand animation of RadTreeView. You can specify the Type and Duration.
To disable expand animation effects you should set the Type to AnimationType.None. To customize the expand animation you can use the ExpandAnimation property.

Example:
cs-api-definition

Gets a collection of RadTreeViewContextMenu objects that represent the context menus of a RadTreeView control.

C#
[PersistenceMode(PersistenceMode.InnerProperty)]
public RadTreeViewContextMenuCollection ContextMenus { get; }
Property Value:

A RadTreeViewContextMenuCollection that contains all the context menus of the RadTreeView control.

By default, if the ContextMenus collection contains RadTreeViewContextMenus, the first one is displayed on the right-click of each RadTreeNode. To disable a context menu for a RadTreeNode, set its EnableContextMenu property to false. To specify a different context menu for a RadTreeNode, use its ContextMenuID property.

Example:
C#
&lt;%@ Register TagPrefix="Telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %&gt;

&lt;html&gt;
&lt;body&gt;
&lt;form id="form1" runat="server"&gt;
&lt;Telerik:RadScriptManager ID="RadScriptManager1" runat="server"&gt;&lt;/Telerik:RadScriptManager&gt;
&lt;br /&gt;
&lt;Telerik:RadTreeView ID="RadTreeView1" runat="server"&gt;
&lt;ContextMenus&gt;
&lt;Telerik:RadTreeViewContextMenu ID="ContextMenu1"&gt;
&lt;nodes&gt;
&lt;Telerik:RadTreeNode Text="Menu1Item1"&gt;&lt;/Telerik:RadTreeNode&gt;
&lt;Telerik:RadTreeNode Text="Menu1Item2"&gt;&lt;/Telerik:RadTreeNode&gt;
&lt;/nodes&gt;
&lt;/Telerik:RadTreeViewContextMenu&gt;
&lt;Telerik:RadTreeViewContextMenu Skin="Outlook" ID="ContextMenu2"&gt;
&lt;nodes&gt;
&lt;Telerik:RadTreeNode Text="Menu2Item1"&gt;&lt;/Telerik:RadTreeNode&gt;
&lt;Telerik:RadTreeNode Text="Menu2Item2"&gt;&lt;/Telerik:RadTreeNode&gt;
&lt;/nodes&gt;
&lt;/Telerik:RadTreeViewContextMenu&gt;
&lt;/ContextMenus&gt;
&lt;Nodes&gt;
&lt;Telerik:RadTreeNode Text="Node1" ContextMenuID="ContextMenu2"&gt;
&lt;Nodes&gt;
&lt;Telerik:RadTreeNode Text="Node11" ContextMenuID="ContextMenu2"&gt;&lt;/Telerik:RadTreeNode&gt;
&lt;Telerik:RadTreeNode Text="Node12" ContextMenuID="ContextMenu2"&gt;&lt;/Telerik:RadTreeNode&gt;
&lt;/Nodes&gt;
&lt;/Telerik:RadTreeNode&gt;
&lt;Telerik:RadTreeNode Text="Node2" ContextMenuID="ContextMenu2"&gt;
&lt;Nodes&gt;
&lt;Telerik:RadTreeNode Text="Node21" ContextMenuID="ContextMenu2"&gt;&lt;/Telerik:RadTreeNode&gt;
&lt;Telerik:RadTreeNode Text="Node22" ContextMenuID="ContextMenu2"&gt;&lt;/Telerik:RadTreeNode&gt;
&lt;/Nodes&gt;
&lt;/Telerik:RadTreeNode&gt;
&lt;/Nodes&gt;
&lt;/Telerik:RadTreeView&gt;

&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;

The CssClass property will now be used instead of the former Skin and will be modified in AddAttributesToRender()

C#
protected override string CssClassFormatString { get; }

Overrides: RadDataBoundControl.CssClassFormatString

Example:
C#
protected override string CssClassFormatString
{
       get
       {
           return "RadDock RadDock_{0} rdWTitle rdWFooter";
       }
}

Gets a collection of RadTreeNodeBindingCollection objects that define the relationship between a data item and the tree node it is binding to.

C#
[PersistenceMode(PersistenceMode.InnerProperty)]
[Browsable(false)]
public RadTreeNodeBindingCollection DataBindings { get; }
Property Value:

A RadTreeNodeBindingCollection that represents the relationship between a data item and the tree node it is binding to.

When set to true enables support for WAI-ARIA

C#
[ClientControlProperty]
[ClientPropertyName("enableAriaSupport")]
public bool EnableAriaSupport { get; set; }

When set to true enables drag-and-drop functionality

C#
[ClientControlProperty]
[ClientPropertyName("enableDragAndDrop")]
public bool EnableDragAndDrop { get; set; }

When set to true enables drag-and-drop visual clue (underline) between nodes while draggin

C#
[ClientControlProperty]
[ClientPropertyName("enableDragAndDropBetweenNodes")]
public bool EnableDragAndDropBetweenNodes { get; set; }

Gets or sets a value indicating whether RadTreeView should HTML encode the text of the nodes.

C#
[ClientControlProperty]
[ClientPropertyName("_enableNodeTextHtmlEncoding")]
public bool EnableNodeTextHtmlEncoding { get; set; }
Property Value:

true if the text should be encoded; otherwise, false. The default value is false.

Gets the settings for the animation played when a node opens.

C#
[PersistenceMode(PersistenceMode.InnerProperty)]
public AnimationSettings ExpandAnimation { get; }
Property Value:

An AnimationSettings that represents the expand animation.

Use the ExpandAnimation property to customize the expand animation of RadTreeView. You can specify the Type and Duration. To disable expand animation effects you should set the Type to AnimationType.None.
To customize the collapse animation you can use the CollapseAnimation property.

Example:
cs-api-definition
void Page_Load(object sender, EventArgs e)
{
RadTreeView1.ExpandAnimation.Type = AnimationType.Linear;
RadTreeView1.ExpandAnimation.Duration = 300;
}

Gets a value indicating whether the RadTreeView control has no nodes.

C#
[Browsable(false)]
public bool IsEmpty { get; }

Gets or sets the loading message that is displayed when child nodes are retrieved on AJAX calls.

C#
[ClientControlProperty]
[ClientPropertyName("loadingMessage")]
public string LoadingMessage { get; set; }

This property can be used for localization purposes (e.g. "Loading..." in different languages).

Example:
cs-api-definition
Protected Sub LoadingMessagePositionChanged(ByVal sender As Object, ByVal e As System.EventArgs)
Select Case LoadingMessagePos.SelectedItem.Value
Case "Before"
RadTree1.LoadingStatusPosition = TreeViewLoadingStatusPosition.BeforeNodeText
RadTree1.LoadingMessage = "(loading ..)"
Case "After"
RadTree1.LoadingStatusPosition = TreeViewLoadingStatusPosition.AfterNodeText
RadTree1.LoadingMessage = "(loading ...)"
Case "Below"
RadTree1.LoadingStatusPosition = TreeViewLoadingStatusPosition.BelowNodeText
RadTree1.LoadingMessage = "(loading ...)"
Case "None"
RadTree1.LoadingStatusPosition = TreeViewLoadingStatusPosition.None
End Select
End Sub

Gets or sets the position of the loading message when child nodes are retrieved on AJAX calls.

C#
[ClientControlProperty]
[ClientPropertyName("loadingStatusPosition")]
public TreeViewLoadingStatusPosition LoadingStatusPosition { get; set; }
Example:
cs-api-definition
Protected Sub LoadingMessagePositionChanged(ByVal sender As Object, ByVal e As System.EventArgs)
Select Case LoadingMessagePos.SelectedItem.Value
Case "Before"
RadTree1.LoadingStatusPosition = TreeViewLoadingStatusPosition.BeforeNodeText
RadTree1.LoadingMessage = "(loading ..)"
Case "After"
RadTree1.LoadingStatusPosition = TreeViewLoadingStatusPosition.AfterNodeText
RadTree1.LoadingMessage = "(loading ...)"
Case "Below"
RadTree1.LoadingStatusPosition = TreeViewLoadingStatusPosition.BelowNodeText
RadTree1.LoadingMessage = "(loading ...)"
Case "None"
RadTree1.LoadingStatusPosition = TreeViewLoadingStatusPosition.None
End Select
End Sub

Gets or sets the loading status template.

C#
[PersistenceMode(PersistenceMode.InnerProperty)]
[Browsable(false)]
[Bindable(false)]
public ITemplate LoadingStatusTemplate { get; set; }
Property Value:

The loading status template.

Gets or sets the maximum number of levels to bind to the RadTreeView control.

C#
public override int MaxDataBindDepth { get; set; }
Property Value:

The maximum number of levels to bind to the RadTreeView control. The default is -1, which binds all the levels in the data source to the control.

Overrides: HierarchicalControlItemContainer.MaxDataBindDepth

When binding the RadTreeView control to a data source, use the MaxDanodeindDepth property to limit the number of levels to bind to the control. For example, setting this property to 2 binds only the root nodes and their immediate children. All remaining records in the data source are ignored.

When set to true the treeview allows multiple node selection (by holding down ctrl key while selecting nodes)

C#
[ClientControlProperty]
[ClientPropertyName("multipleSelect")]
public bool MultipleSelect { get; set; }

Gets a RadTreeNodeCollection object that contains the root nodes of the current RadTreeView control.

C#
[PersistenceMode(PersistenceMode.InnerProperty)]
public RadTreeNodeCollection Nodes { get; }
Property Value:

A RadTreeNodeCollection that contains the root nodes of the current RadTreeView control. By default the collection is empty (RadTreeView has no children).

Implements: IRadTreeNodeContainer.Nodes

Use the nodes property to access the root nodes of the RadTreeView control. You can also use the nodes property to manage the root nodes - you can add, remove or modify nodes.

Example:
cs-api-definition
RadTreeView1.Nodes[0].Text = "Example";
RadTreeView1.Nodes[0].NavigateUrl = "http://www.example.com";

Gets or sets the template for displaying all node in the current RadTreeView.

C#
[TemplateContainer(typeof(RadTreeNode))]
[PersistenceMode(PersistenceMode.InnerProperty)]
[Browsable(false)]
[Bindable(false)]
public virtual ITemplate NodeTemplate { get; set; }
Property Value:

An object implementing the ITemplate interface. The default value is a null reference (Nothing in Visual Basic), which indicates that this property is not set.

The name of the JavaScript function that will be called after the user clicks on a context menu item.

C#
[ClientControlEvent]
[ClientPropertyName("contextMenuItemClicked")]
public string OnClientContextMenuItemClicked { get; set; }

The name of the JavaScript function that will be called when the user clicks on a context menu item.

C#
[ClientControlEvent]
[ClientPropertyName("contextMenuItemClicking")]
public string OnClientContextMenuItemClicking { get; set; }

The name of the JavaScript function that will be called when a context menu is to be displayed.

C#
[ClientControlEvent]
[ClientPropertyName("contextMenuShowing")]
public string OnClientContextMenuShowing { get; set; }

The name of the JavaScript function that will be called after context menu is displayed.

C#
[ClientControlEvent]
[ClientPropertyName("contextMenuShown")]
public string OnClientContextMenuShown { get; set; }

The name of the JavaScript function that will be called when the user double clicks on a node.

C#
[ClientControlEvent]
[ClientPropertyName("nodeDoubleClick")]
public string OnClientDoubleClick { get; set; }

The name of the JavaScript function that will be called when a key is pressed.

C#
[ClientControlEvent]
[ClientPropertyName("keyPressing")]
public string OnClientKeyPressing { get; set; }

Gets or sets the name of the JavaScript function called when the control is fully initialized on the client side.

C#
[ClientControlEvent]
[ClientPropertyName("load")]
public string OnClientLoad { get; set; }

The name of the JavaScript function that will be called when the mouse hovers away from the TreeView.

C#
[ClientControlEvent]
[ClientPropertyName("mouseOut")]
public string OnClientMouseOut { get; set; }

The name of the JavaScript function that will be called when the user highlights a treenode.

C#
[ClientControlEvent]
[ClientPropertyName("mouseOver")]
public string OnClientMouseOver { get; set; }

Gets or sets the name of the JavaScript function called when a node's expand/collapse animation finishes

C#
[ClientControlEvent]
[ClientPropertyName("nodeAnimationEnd")]
public string OnClientNodeAnimationEnd { get; set; }

The name of the JavaScript function that will be called after the user checks (checkbox) a treenode.

C#
[ClientControlEvent]
[ClientPropertyName("nodeChecked")]
public string OnClientNodeChecked { get; set; }

The name of the JavaScript function that will be called when the user checks (checkbox) a treenode.

C#
[ClientControlEvent]
[ClientPropertyName("nodeChecking")]
public string OnClientNodeChecking { get; set; }

The name of the JavaScript function that will be called after click on a treenode. Used for AJAX/callback hooks.

C#
[ClientControlEvent]
[ClientPropertyName("nodeClicked")]
public string OnClientNodeClicked { get; set; }

The name of the JavaScript function that will be called upon click on a treenode. The function must accept a single parameter which is the instance of the node clicked. For example if you define OnClientClick="ProcessClientClick", you must define a javascript function defined in the following way (example):

function ProcessClientClick(node) { alert("You clicked on: " + node.Text); }

C#
[ClientControlEvent]
[ClientPropertyName("nodeClicking")]
public string OnClientNodeClicking { get; set; }

The name of the JavaScript function that will be called after a node is collapsed.

C#
[ClientControlEvent]
[ClientPropertyName("nodeCollapsed")]
public string OnClientNodeCollapsed { get; set; }

The name of the JavaScript function that will be called before a node is collapsed.

C#
[ClientControlEvent]
[ClientPropertyName("nodeCollapsing")]
public string OnClientNodeCollapsing { get; set; }

Gets or sets the name of the JavaScript function called when a node is databound during load on demand

C#
[ClientControlEvent]
[ClientPropertyName("nodeDataBound")]
public string OnClientNodeDataBound { get; set; }

The name of the JavaScript function that will be called when the user moves the mouse while dragging a node.

C#
[ClientControlEvent]
[ClientPropertyName("nodeDragging")]
public string OnClientNodeDragging { get; set; }

The name of the JavaScript function that will be called when the user starts dragging a node.

C#
[ClientControlEvent]
[ClientPropertyName("nodeDragStart")]
public string OnClientNodeDragStart { get; set; }

The name of the JavaScript function that will be called after the user drops a node onto another node.

C#
[ClientControlEvent]
[ClientPropertyName("nodeDropped")]
public string OnClientNodeDropped { get; set; }

The name of the JavaScript function that will be called when the user drops a node onto another node.

C#
[ClientControlEvent]
[ClientPropertyName("nodeDropping")]
public string OnClientNodeDropping { get; set; }

The name of the JavaScript function that will be called after the user edits a node

C#
[ClientControlEvent]
[ClientPropertyName("nodeEdited")]
public string OnClientNodeEdited { get; set; }

The name of the JavaScript function that will be called before the user edits a node

C#
[ClientControlEvent]
[ClientPropertyName("nodeEditing")]
public string OnClientNodeEditing { get; set; }

Gets or sets the name of the JavaScript function called when a node starts being edited

C#
[ClientControlEvent]
[ClientPropertyName("nodeEditStart")]
public string OnClientNodeEditStart { get; set; }

The name of the JavaScript function that will be called after a node is expanded.

C#
[ClientControlEvent]
[ClientPropertyName("nodeExpanded")]
public string OnClientNodeExpanded { get; set; }

The name of the JavaScript function that will be called before a node is expanded.

C#
[ClientControlEvent]
[ClientPropertyName("nodeExpanding")]
public string OnClientNodeExpanding { get; set; }

Gets or sets a value indicating the client-side event handler that is called when the children of a tree node were just populated (for example from web service).

C#
[ClientControlEvent]
[ClientPropertyName("nodePopulated")]
public string OnClientNodePopulated { get; set; }
Property Value:

A string specifying the name of the JavaScript function that will handle the event. The default value is empty string.

If specified, the OnClientNodePopulated client-side event handler is called when the children of a tree node were just populated. Two parameters are passed to the handler:

  • sender, the menu client object;
  • eventArgs with one property:
    • get_node(), the instance of the tree node.

This event cannot be cancelled.

Example:
C#
<p>&lt;script type="text/javascript"&gt;<br />
function onClientNodePopulatedHandler(sender, eventArgs)<br />
{<br />
       var node = eventArgs.get_node();<br />
       alert("Loading finished for " + node.get_text());<br />
}<br />
&lt;/script&gt;</p>
<p>&lt;telerik:RadTreeView ID="RadTreeView1"<br />
runat="server"<br />
    <strong>OnClientNodePopulated="onClientNodePopulatedHandler"</strong>&gt;<br />
....<br />
&lt;/telerik:RadTreeView&gt;</p>

Gets or sets a value indicating the client-side event handler that is called when the children of a tree node are about to be populated (for example from web service).

C#
[ClientControlEvent]
[ClientPropertyName("nodePopulating")]
public string OnClientNodePopulating { get; set; }
Property Value:

A string specifying the name of the JavaScript function that will handle the event. The default value is empty string.

If specified, the OnClientNodePopulating client-side event handler is called when the children of a tree node are about to be populated. Two parameters are passed to the handler:

    This event can be cancelled.

    Example:
    C#
    <p>&lt;script type="text/javascript"&gt;<br />
    function onClientNodePopulatingHandler(sender, eventArgs)<br />
    {<br />
           var node = eventArgs.get_node();<br />
           var context = eventArgs.get_context();<br />
           context["CategoryID"] = node.get_value();<br />
    }<br />
    &lt;/script&gt;</p>
    <p>&lt;telerik:RadTreeView ID="RadTreeView1"<br />
    runat="server"<br />
        <strong>OnClientNodePopulating="onClientNodePopulatingHandler"</strong>&gt;<br />
    ....<br />
    &lt;/telerik:RadTreeView&gt;</p>

    Gets or sets a value indicating the client-side event handler that is called when the operation for populating the children of a tree node has failed.

    C#
    [ClientControlEvent]
    [ClientPropertyName("nodePopulationFailed")]
    public string OnClientNodePopulationFailed { get; set; }
    Property Value:

    A string specifying the name of the JavaScript function that will handle the event. The default value is empty string.

    If specified, the OnClientNodePopulationFailed client-side event handler is called when the operation to populate the children of a tree node has failed. Two parameters are passed to the handler:

    • sender, the menu client object;
    • eventArgs with three properties:
      • get_node(), the instance of the tree node.
      • set_cancel(), set to true to suppress the default action (alert message).

    This event cannot be cancelled.

    Example:
    C#
    <p>&lt;script type="text/javascript"&gt;<br />
    function onClientNodePopulationFailedHandler(sender, eventArgs)<br />
    {<br />
           var node = eventArgs.get_node();<br />
           var errorMessage = eventArgs.get_errorMessage();<br />
           <br />
           alert("Error: " + errorMessage);<br />
           eventArgs.set_cancel(true);<br />
    }<br />
    &lt;/script&gt;</p>
    <p>&lt;telerik:RadTreeView ID="RadTreeView1"<br />
    runat="server"<br />
        <strong>OnClientNodePopulationFailed="onClientNodePopulationFailedHandler"</strong>&gt;<br />
    ....<br />
    &lt;/telerik:RadTreeView&gt;</p>

    Gets or sets the name of the JavaScript function called when the client template for a node is evaluated

    C#
    [ClientControlEvent]
    [ClientPropertyName("templateDataBound")]
    public string OnClientTemplateDataBound { get; set; }

    Gets or sets the OnClientTreePopulated event value in the ViewState.

    C#
    [ClientControlEvent]
    [ClientPropertyName("treePopulated")]
    public string OnClientTreePopulated { get; set; }
    Property Value:

    The OnClientTreePopulated.

    Gets or sets the OnClientTreePopulating event value in the ViewState.

    C#
    [ClientControlEvent]
    [ClientPropertyName("treePopulating")]
    public string OnClientTreePopulating { get; set; }
    Property Value:

    The OnClientTreePopulating.

    When set to true, the nodes populated through Load On Demand are persisted on the server.

    C#
    [ClientControlProperty]
    [ClientPropertyName("persistLoadOnDemandNodes")]
    public bool PersistLoadOnDemandNodes { get; set; }

    Gets or sets the URL of the page to post to from the current page when a tree node is clicked.

    C#
    public override string PostBackUrl { get; set; }
    Property Value:

    The URL of the Web page to post to from the current page when a tree node is clicked. The default value is an empty string (""), which causes the page to post back to itself.

    Overrides: ControlItemContainer.PostBackUrl

    Gets a RadTreeNode object that represents the selected node in the RadTreeView control.

    C#
    [Browsable(false)]
    public RadTreeNode SelectedNode { get; }

    When a node is in selection mode, the user can select a node by clicking on the text in the node. Use the SelectedNode property to determine which node is selected in the TreeView control.

    A node cannot be selected when the TreeView control displays hyperlinks. When hyperlinks are displayed, the SelectedNode property always returns a null reference (Nothing in Visual Basic).

    When the user selects a different node in the RadTreeView control by clicking the text in the new node, the NodeClick event is raised, by default. If you set the MultipleSelect property of the treeview to true, end-users can select multiple nodes by holding the Ctrl / Shift keys while selecting.

    Example:
    cs-api-definition
    &lt;radT:RadTreeView
    ID="RadTree1"
    runat="server"
    OnNodeClick="NodeClick"
    /&gt;
    
    Protected Sub NodeClick(ByVal sender As Object, ByVal NodeEventArgs As RadTreeNodeEventArgs)
    info.Text = String.Empty
    Dim NodeClicked As RadTreeNode = NodeEventArgs.NodeClicked
    info.Text = NodeClicked.Text
    End Sub

    Gets a collection of RadTreeNode objects that represent the nodes in the control that are currently selected.

    C#
    [Browsable(false)]
    public IList<RadTreeNode> SelectedNodes { get; }
    Property Value:

    An IList<RadTreeNode> containing the selected nodes.

    This collection is commonly used to iterate through all the nodes that have been selected in the tree.

    The SelectedNodes collection is populated using a depth-first traversal of the tree structure: each parent node is processed down to its child nodes before the next parent node is populated.

    Gets the Value of the selected node.

    C#
    [Browsable(false)]
    [ClientControlProperty]
    [ClientPropertyName("_selectedValue")]
    public string SelectedValue { get; }
    Property Value:

    The Value of the selected node. If there is no selected node returns empty string.

    Gets a value indicating whether the dotted lines indenting the nodes should be displayed or not.

    C#
    [ClientControlProperty]
    [ClientPropertyName("_showLineImages")]
    public bool ShowLineImages { get; set; }

    Gets a value indicating whether only the current branch of the treeview is expanded.

    C#
    [ClientControlProperty]
    [ClientPropertyName("singleExpandPath")]
    public bool SingleExpandPath { get; set; }

    The property closes all nodes that are not parents of the last expanded node. This property is only effective on the client browser - in postback modes you need to handle the logic yourself.

    C#
    protected override bool SupportsRenderingMode { get; }

    Overrides: RadDataBoundControl.SupportsRenderingMode

    Gets or sets a value indicating whether RadTreeView should display tri-state checkboxes.

    C#
    [ClientControlProperty]
    [ClientPropertyName("_threeState")]
    public bool TriStateCheckBoxes { get; set; }
    Property Value:

    true if tri-state checkboxes should be displayed; otherwise, false. The default value is false.

    Enabling three state checkbox support requires the CheckBoxes property to be set to true.

    Gets the unique, hierarchically qualified identifier for the server control.

    C#
    [ClientControlProperty]
    [ClientPropertyName("_uniqueId")]
    public override string UniqueID { get; }
    Property Value:

    The fully qualified identifier for the server control.

    Overrides: Control.UniqueID

    Gets the settings for the web service used to populate nodes when ExpandMode set to WebService.

    C#
    [PersistenceMode(PersistenceMode.InnerProperty)]
    public NavigationControlWebServiceSettings WebServiceSettings { get; }
    Property Value:

    An WebServiceSettings that represents the web service used for populating nodes.

    Use the WebServiceSettings property to configure the web service used to populate nodes on demand. You must specify both Path and Method to fully describe the service.

    You can use the LoadingStatusTemplate property to create a loading template.

    In order to use the integrated support, the web service should have the following signature:

       <pre><code class="lang-csharp">[ScriptService]

    public class WebServiceName : WebService { [WebMethod] public RadTreeNodeData[] WebServiceMethodName(RadTreeNodeData item, object context) { // We cannot use a dictionary as a parameter, because it is only supported by script services. // The context object should be cast to a dictionary at runtime. IDictionary<string, object> contextDictionary = (IDictionary<string, object>) context;

        //...
    }

    }

    Methods

    C#
    protected override void AddAttributesToRender(HtmlTextWriter writer)
    Parameters:writerHtmlTextWriter

    Overrides: RadDataBoundControl.AddAttributesToRender(HtmlTextWriter)

    Checks all nodes of the current RadTreeView object.

    C#
    public void CheckAllNodes()

    Collapses all nodes in the tree.

    C#
    public void CollapseAllNodes()
    C#
    protected override ControlItemCollection CreateChildItemCollection()
    Returns:

    ControlItemCollection

    Overrides: ControlItemContainer.CreateChildItemCollection()

    C#
    protected override IRenderer CreateControlRenderer()
    Returns:

    IRenderer

    Overrides: RadDataBoundControl.CreateControlRenderer()

    C#
    protected override NavigationItemBindingCollection CreateDataBindings()
    Returns:

    NavigationItemBindingCollection

    Overrides: HierarchicalControlItemContainer.CreateDataBindings()

    C#
    protected override ControlItem CreateItem()
    Returns:

    ControlItem

    Overrides: ControlItemContainer.CreateItem()

    C#
    protected override void DescribeClientEvents(IScriptDescriptor descriptor)
    Parameters:descriptorIScriptDescriptor

    Overrides: RadDataBoundControl.DescribeClientEvents(IScriptDescriptor)

    C#
    protected override void DescribeClientProperties(IScriptDescriptor descriptor)
    Parameters:descriptorIScriptDescriptor

    Overrides: RadDataBoundControl.DescribeClientProperties(IScriptDescriptor)

    C#
    protected override void DescribeComponent(IScriptDescriptor descriptor)
    Parameters:descriptorIScriptDescriptor

    Overrides: ControlItemContainer.DescribeComponent(IScriptDescriptor)

    Expands all nodes in the tree.

    C#
    public void ExpandAllNodes()

    Returns the first RadTreeNode that matches the conditions defined by the specified predicate. The predicate should returns a boolean value.

    C#
    public RadTreeNode FindNode(Predicate<RadTreeNode> match)
    Parameters:matchPredicate<RadTreeNode>

    The Predicate <> that defines the conditions of the element to search for.

    Returns:

    RadTreeNode

    Example:
    cs-api-definition
    void Page_Load(object sender, EventArgs e)
    {
    RadTreeView1.FindNode(NodeWithEqualsTextAndValue);
    }
    private static bool NodeWithEqualsTextAndValue(RadTreeNode node)
    {
    if (node.Text == node.Value)
    {
    return true;
    }
    else
    {
    return false;
    }
    }

    Searches all nodes for a RadTreeNode which contains the specified attribute and attribute value.

    C#
    public RadTreeNode FindNodeByAttribute(string attributeName, string attributeValue)
    Parameters:attributeNamestring

    The name of the target attribute.

    attributeValuestring

    The value of the target attribute

    Returns:

    RadTreeNode

    The RadTreeNode that matches the specified arguments. Null (Nothing) is returned if no node is found.

    Searches all nodes for a RadTreeNode with a Text property equal to the specified text.

    C#
    public RadTreeNode FindNodeByText(string text, bool ignoreCase)
    Parameters:textstring

    The text to search for

    ignoreCasebool

    A Boolean indicating a case-sensitive or insensitive comparison (true indicates a case-insensitive comparison).

    Returns:

    RadTreeNode

    A RadTreeNode whose Text property equals to the specified argument. Null (Nothing) is returned when no matching node is found.

    Searches all nodes for a RadTreeNode with a Text property equal to the specified text.

    C#
    public RadTreeNode FindNodeByText(string text)
    Parameters:textstring

    The text to search for

    Returns:

    RadTreeNode

    A RadTreeNode whose Text property equals to the specified argument. Null (Nothing) is returned when no matching node is found.

    Searches all nodes for a RadTreeNode with a NavigateUrl property equal to the specified URL.

    C#
    public RadTreeNode FindNodeByUrl(string url)
    Parameters:urlstring

    The URL to search for

    Returns:

    RadTreeNode

    A RadTreeNode whose NavigateUrl property equals to the specified argument. Null (Nothing) is returned when no matching node is found.

    The ResolveUrl method is used to resolve NavigateUrl property before comparing it to the specified URL.

    Searches all nodes for a RadTreeNode with a Value property equal to the specified value.

    C#
    public RadTreeNode FindNodeByValue(string value, bool ignoreCase)
    Parameters:valuestring

    The value to search for

    ignoreCasebool

    A Boolean indicating a case-sensitive or insensitive comparison (true indicates a case-insensitive comparison).

    Returns:

    RadTreeNode

    A RadTreeNode whose Value property equals to the specified argument. Null (Nothing) is returned when no matching node is found.

    Searches all nodes for a RadTreeNode with a Value property equal to the specified value.

    C#
    public RadTreeNode FindNodeByValue(string value)
    Parameters:valuestring

    The value to search for

    Returns:

    RadTreeNode

    A RadTreeNode whose Value property equals to the specified argument. Null (Nothing) is returned when no matching node is found.

    Gets a linear list of all nodes in the RadTreeView control.

    C#
    public IList<RadTreeNode> GetAllNodes()
    Returns:

    IList<RadTreeNode>

    An IList<T> containing all nodes (from all hierarchy levels).

    Populates the control from the specified XML file.

    C#
    public override void LoadContentFile(string fileName)
    Parameters:fileNamestring

    The name of the XML file.

    Overrides: HierarchicalControlItemContainer.LoadContentFile(string)

    Executed when post data is loaded from the request

    C#
    protected override bool LoadPostData(string postDataKey, NameValueCollection postCollection)
    Parameters:postDataKeystringpostCollectionNameValueCollectionReturns:

    bool

    Overrides: RadDataBoundControl.LoadPostData(string, NameValueCollection)

    C#
    protected override void LoadViewState(object savedState)
    Parameters:savedStateobject

    Overrides: HierarchicalControlItemContainer.LoadViewState(object)

    Loads the control from an XML string. Identical to LoadXml.

    C#
    public void LoadXmlString(string xml)
    Parameters:xmlstring

    The XML string to populate from.

    C#
    protected virtual void OnContextMenuItemClick(RadTreeViewContextMenuEventArgs e)
    Parameters:eRadTreeViewContextMenuEventArgs
    C#
    protected virtual void OnNodeCheck(RadTreeNodeEventArgs e)
    Parameters:eRadTreeNodeEventArgs
    C#
    protected virtual void OnNodeClick(RadTreeNodeEventArgs e)
    Parameters:eRadTreeNodeEventArgs
    C#
    protected virtual void OnNodeCollapse(RadTreeNodeEventArgs e)
    Parameters:eRadTreeNodeEventArgs
    C#
    protected virtual void OnNodeCreated(RadTreeNodeEventArgs e)
    Parameters:eRadTreeNodeEventArgs
    C#
    protected virtual void OnNodeDataBound(RadTreeNodeEventArgs e)
    Parameters:eRadTreeNodeEventArgs
    C#
    protected virtual void OnNodeDrop(RadTreeNodeDragDropEventArgs e)
    Parameters:eRadTreeNodeDragDropEventArgs
    C#
    protected virtual void OnNodeEdit(RadTreeNodeEditEventArgs e)
    Parameters:eRadTreeNodeEditEventArgs
    C#
    protected virtual void OnNodeExpand(RadTreeNodeEventArgs e)
    Parameters:eRadTreeNodeEventArgs
    C#
    protected override void OnPreRender(EventArgs e)
    Parameters:eEventArgs

    Overrides: RadDataBoundControl.OnPreRender(EventArgs)

    C#
    protected virtual void OnTemplateNeeded(RadTreeNodeEventArgs e)
    Parameters:eRadTreeNodeEventArgs
    C#
    protected override void RaiseItemCreated(ControlItem item)
    Parameters:itemControlItem

    Overrides: ControlItemContainer.RaiseItemCreated(ControlItem)

    C#
    protected override void RaiseItemDataBound(ControlItem item)
    Parameters:itemControlItem

    Overrides: ControlItemContainer.RaiseItemDataBound(ControlItem)

    C#
    protected virtual void RaisePostBackEvent(string eventArgument)
    Parameters:eventArgumentstring
    C#
    protected override void RaiseTemplateNeeded(ControlItem item)
    Parameters:itemControlItem

    Overrides: ControlItemContainer.RaiseTemplateNeeded(ControlItem)

    C#
    protected override void RenderContents(HtmlTextWriter writer)
    Parameters:writerHtmlTextWriter

    Overrides: RadDataBoundControl.RenderContents(HtmlTextWriter)

    C#
    protected override object SaveViewState()
    Returns:

    object

    Overrides: HierarchicalControlItemContainer.SaveViewState()

    C#
    protected override void TrackViewState()

    Overrides: HierarchicalControlItemContainer.TrackViewState()

    This method unchecks all nodes of the current RadTreeView instance. Useful when you need to uncheck all nodes after postback.

    C#
    public void UncheckAllNodes()

    This method unselects all nodes of the current RadTreeView instance. Useful when you need to clear node selection after postback.

    C#
    public void UnselectAllNodes()

    Events

    Occurs on the server when a item in the RadTreeViewContextMenu is clicked.

    C#
    public event RadTreeViewContextMenuEventHandler ContextMenuItemClick

    The context menu will also postback if you navigate to a menu item using the [menu item] key and then press [enter] on the menu item that is focused. The instance of the clicked menu item is passed to the ContextMenuItemClick event handler - you can obtain a reference to it using the eventArgs.Item property.

    Occurs when a node is checked.

    C#
    public event RadTreeViewEventHandler NodeCheck

    Occurs on the server when a node in the RadTreeView control is clicked.

    C#
    public event RadTreeViewEventHandler NodeClick
    Example:
    cs-api-definition
    protected void RadTreeView1_NodeClick(object sender, Telerik.Web.UI.RadTreeNodeEventArgs e)
    {
    Response.Write("Clicked node is " + e.Node.Text);
    }

    Occurs when a node is collapsed.

    C#
    public event RadTreeViewEventHandler NodeCollapse

    The NodeCollapse event is raised only for nodes whose ExpandMode property is set to ServerSide.

    Occurs when a node is created.

    C#
    public event RadTreeViewEventHandler NodeCreated

    The NodeCreated event is raised when an node in the RadTreeView control is created, both during round-trips and at the time data is bound to the control. The NodeCreated event is not raised for nodes which are defined inline in the page or user control.

    The NodeCreated event is commonly used to initialize node properties.

    Example:
    cs-api-definition
    protected void RadTreeView1_NodeCreated(object sender, Telerik.Web.UI.RadTreeNodeEventArgs e)
    {
    e.Node.ToolTip = e.Node.Text;
    }

    Occurs when a node is data bound.

    C#
    public event RadTreeViewEventHandler NodeDataBound

    The NodeDataBound event is raised for each node upon danodeinding. You can retrieve the node being bound using the event arguments. The DataItem associated with the node can be retrieved using the DataItem property.

    The NodeDataBound event is often used in scenarios when you want to perform additional mapping of fields from the DataItem to their respective properties in the RadTreeNode class.

    Example:
    cs-api-definition
    protected void RadTreeView1_NodeDataBound(object sender, Telerik.Web.UI.RadTreeNodeEventArgs e)
    {
    e.Node.ImageUrl = "image" + (string)DataBinder.Eval(e.Node.DataItem, "ID") + ".gif";
    e.Node.NavigateUrl = (string)DataBinder.Eval(e.Node.DataItem, "URL");
    }

    Occurs when a node (or nodes) is dragged and dropped.

    C#
    public event RadTreeViewDragDropEventHandler NodeDrop

    The NodeDrop event is commonly used to move nodes from one location into other.

    Example:
    cs-api-definition
    protected void RadTreeView1_NodeDrop(object sender, RadTreeNodeDragDropEventArgs e)
    {
    foreach (RadTreeNode sourceNode in e.DraggedNodes)
    {
    if (!sourceNode.IsAncestorOf(e.DestDragNode))
    {
    sourceNode.Remove();
    e.DestDragNode.Nodes.Add(sourceNode);
    }
    }
    }

    Occurs when a node's text is edited.

    C#
    public event RadTreeViewEditEventHandler NodeEdit

    The NodeEdit event is commonly used to update the Text property after editing.

    Example:
    cs-api-definition
    protected void RadTreeView1_NodeEdit(object sender, RadTreeNodeEditEventArgs e)
    {
    RadTreeNode nodeEdited = e.Node;
    string newText = e.Text;
    nodeEdited.Text = newText;
    }

    Occurs when a node is expanded.

    C#
    public event RadTreeViewEventHandler NodeExpand

    The NodeExpand event will be raised for nodes whose ExpandMode property is set to ServerSide or ServerSideCallback.

    The NodeExpand event is commonly used to populate nodes on demand.

    Example:
    cs-api-definition
    protected void RadTreeView1_NodeExpanded(object sender, Telerik.Web.UI.RadTreeNodeEventArgs e)
    {
    RadTreeNode nodeCreatedOnDemand = new RadTreeNode("Node created on demand");
    e.Node.Nodes.Add(nodeCreatedOnDemand);
    }

    Occurs before template is being applied to the node.

    C#
    public event RadTreeViewEventHandler TemplateNeeded

    The TemplateNeeded event is raised before a template is been applied on the node, both during round-trips (postbacks) and at the time data is bound to the control. The TemplateNeeded event is not raised for nodes which are defined inline in the page or user control.

    The TemplateNeeded event is commonly used for dynamic templating.

    Example:
    cs-api-definition
    protected void RadTreeView1_TemplateNeeded(object sender, Telerik.Web.UI.RadTreeNodeEventArgs e)
    {
    string value = e.Node.Value;
    if (value != null)
    {
    // if the value is an even number
    if ((Int32.Parse(value) % 2) == 0)
    {
    var textBoxTemplate = new TextBoxTemplate();
    e.Node.NodeTemplate = textBoxTemplate;
    }
    }
    }
    In this article
    DefinitionConstructorsRadTreeView()PropertiesAllowNodeEditingCheckBoxesCheckChildNodesCheckedNodesClientChangesClientNodeTemplateCollapseAnimationContextMenusCssClassFormatStringDataBindingsEnableAriaSupportEnableDragAndDropEnableDragAndDropBetweenNodesEnableNodeTextHtmlEncodingExpandAnimationIsEmptyLoadingMessageLoadingStatusPositionLoadingStatusTemplateMaxDataBindDepthMultipleSelectNodesNodeTemplateOnClientContextMenuItemClickedOnClientContextMenuItemClickingOnClientContextMenuShowingOnClientContextMenuShownOnClientDoubleClickOnClientKeyPressingOnClientLoadOnClientMouseOutOnClientMouseOverOnClientNodeAnimationEndOnClientNodeCheckedOnClientNodeCheckingOnClientNodeClickedOnClientNodeClickingOnClientNodeCollapsedOnClientNodeCollapsingOnClientNodeDataBoundOnClientNodeDraggingOnClientNodeDragStartOnClientNodeDroppedOnClientNodeDroppingOnClientNodeEditedOnClientNodeEditingOnClientNodeEditStartOnClientNodeExpandedOnClientNodeExpandingOnClientNodePopulatedOnClientNodePopulatingOnClientNodePopulationFailedOnClientTemplateDataBoundOnClientTreePopulatedOnClientTreePopulatingPersistLoadOnDemandNodesPostBackUrlSelectedNodeSelectedNodesSelectedValueShowLineImagesSingleExpandPathSupportsRenderingModeTriStateCheckBoxesUniqueIDWebServiceSettingsMethodsAddAttributesToRender(HtmlTextWriter)CheckAllNodes()CollapseAllNodes()CreateChildItemCollection()CreateControlRenderer()CreateDataBindings()CreateItem()DescribeClientEvents(IScriptDescriptor)DescribeClientProperties(IScriptDescriptor)DescribeComponent(IScriptDescriptor)ExpandAllNodes()FindNode(Predicate<RadTreeNode>)FindNodeByAttribute(string, string)FindNodeByText(string, bool)FindNodeByText(string)FindNodeByUrl(string)FindNodeByValue(string, bool)FindNodeByValue(string)GetAllNodes()LoadContentFile(string)LoadPostData(string, NameValueCollection)LoadViewState(object)LoadXmlString(string)OnContextMenuItemClick(RadTreeViewContextMenuEventArgs)OnNodeCheck(RadTreeNodeEventArgs)OnNodeClick(RadTreeNodeEventArgs)OnNodeCollapse(RadTreeNodeEventArgs)OnNodeCreated(RadTreeNodeEventArgs)OnNodeDataBound(RadTreeNodeEventArgs)OnNodeDrop(RadTreeNodeDragDropEventArgs)OnNodeEdit(RadTreeNodeEditEventArgs)OnNodeExpand(RadTreeNodeEventArgs)OnPreRender(EventArgs)OnTemplateNeeded(RadTreeNodeEventArgs)RaiseItemCreated(ControlItem)RaiseItemDataBound(ControlItem)RaisePostBackEvent(string)RaiseTemplateNeeded(ControlItem)RenderContents(HtmlTextWriter)SaveViewState()TrackViewState()UncheckAllNodes()UnselectAllNodes()EventsContextMenuItemClickNodeCheckNodeClickNodeCollapseNodeCreatedNodeDataBoundNodeDropNodeEditNodeExpandTemplateNeeded
    Not finding the help you need?
    Contact Support