RadTreeNode
This Class defiens the RadTreeNode object.
The RadTreeView control is made up of nodes. Nodes which are immediate children of the treeview are root nodes. Nodes which are children of root nodes are child nodes.
A node usually stores data in two properties, the Text property and the Value property. The value of the Text property is displayed in the RadTreeView control, and the Value property is used to store additional data.
To create tree nodes, use one of the following methods:
- Use declarative syntax to define nodes inline in your page or user control.
- Use one of the constructors to dynamically create new instances of the RadTreeNode class. These nodes can then be added to the Nodes collection of another node or treeview.
- Data bind the RadTreeView control to a data source.
When the user clicks a tree node, the RadTreeView control can navigate to a linked Web page, post back to the server or select that node. If the NavigateUrl property of a node is set, the RadTreeView control navigates to the linked page. By default, a linked page is displayed in the same window or frame. To display the linked content in a different window or frame, use the Target property.
Definition
Namespace:Telerik.Web.UI
Assembly:Telerik.Web.UI.dll
Syntax:
public class RadTreeNode : NavigationItem, IComponent, IDisposable, IParserAccessor, IUrlResolutionService, IDataBindingsAccessor, IControlBuilderAccessor, IControlDesignerAccessor, IExpressionsAccessor, IAttributeAccessor, IMarkableStateManager, IStateManager, INamingContainer, IXmlSerializable, IControlItemContainer, IRadTreeNodeContainer, ICloneable, ITreeNodeBase
Inheritance: objectControlWebControlControlItemNavigationItemRadTreeNode...
Implements:
Inherited Members
Constructors
Initializes a new instance of the RadTreeNode class.
public RadTreeNode()
Use this constructor to create and initialize a new instance of the RadTreeNode class using default values.
Initializes a new instance of the RadTreeNode class with the specified text, value and URL.
public RadTreeNode(string text, string value, string navigateUrl)
The text of the node. The Text property is set to the value of this parameter.
valuestringThe value of the node. The Value property is set to the value of this parameter.
navigateUrlstringThe url which the node will navigate to. The NavigateUrl property is set to the value of this parameter.
Use this constructor to create and initialize a new instance of the RadTreeNode class using the specified text, value and URL.
Initializes a new instance of the RadTreeNode class with the specified text and value.
public RadTreeNode(string text, string value)
The text of the node. The Text property is set to the value of this parameter.
valuestringThe value of the node. The Value property is set to the value of this parameter.
Use this constructor to create and initialize a new instance of the RadTreeNode class using the specified text and value.
Initializes a new instance of the RadTreeNode class with the specified text data.
public RadTreeNode(string text)
The text of the node. The Text property is set to the value of this parameter.
Use this constructor to create and initialize a new instance of the RadTreeNode class using the specified text.
Properties
Gets or sets a value indicating whether the node can be dragged and dropped.
[ClientPersistedProperty]
public bool AllowDrag { get; set; }
True if the user is able drag and drop the node; otherwise false.
The default value is true.
Gets or sets a value indicating whether the use can drag and drop nodes over this node.
[ClientPersistedProperty]
public bool AllowDrop { get; set; }
True if the user is able to drag and drop nodes over this node; otherwise
false. The default value is true.
Gets or sets a value indicating whether the use can edit the text of the node.
[ClientPersistedProperty]
public bool AllowEdit { get; set; }
True if the node is editable; otherwise false. The default value
is true.
Gets or sets the category of the node.
[ClientPersistedProperty]
public string Category { get; set; }
The
Categoryproperty is similar to the Value property. You can use it to associate custom data with the node.
Gets or sets a value indicating whether the node is checkable. A checkbox control is rendered for checkable nodes.
[ClientPersistedProperty]
public bool Checkable { get; set; }
If the CheckBoxes property set to
true, RadTreeView automatically displays a checkbox next to each node. You can set theCheckableproperty tofalsefor nodes that do not need to display a checkbox.
Gets or sets a value indicating whether the node is checked or not.
public bool Checked { get; set; }
True if the node is checked; otherwise false. The default value
is false
Gets the checked state of the tree node
[Browsable(false)]
public TreeNodeCheckState CheckState { get; }
One of the TreeNodeCheckState values.
Gets or sets the Cascading Style Sheet (CSS) class applied to the content wrapper of the node.
[ClientPersistedProperty]
public string ContentCssClass { get; set; }
You can use the ContentCssClass property to specify unique appearance for a node content area and its children. Useful when using CSS sprites.
Gets or sets a value indicating the ID of the RadTreeViewContextMenu displayed for the current node.
[TypeConverter(typeof(TreeNodeContextMenuIDConverter))]
[ClientPersistedProperty]
public string ContextMenuID { get; set; }
A string representing the ID of the context menu associated with the current node. The default value is empty string.
If the ContextMenuID property is not set the first context menu from the ContextMenus collection will be used.
Gets or sets the Cascading Style Sheet (CSS) class applied by default to the node.
[ClientPersistedProperty]
public override string CssClass { get; set; }
Overrides:
By default the visual appearance of hovered nodes is defined in the skin CSS file. You can use the CssClass property to specify unique appearance for the node.
Gets the data item that is bound to the node
[Browsable(false)]
public override object DataItem { get; set; }
An Object that represents the data item that is bound to the node. The default value is null (Nothing in Visual Basic), which indicates that the node is not bound to any data item. The return value will always be null unless accessed within a NodeDataBound event handler.
Overrides:
This property is applicable only during data binding. Use it along with the NodeDataBound event to perform additional mapping of fields from the data item to RadTreeNode properties.
Gets or sets the Cascading Style Sheet (CSS) class applied to the node when it is disabled.
[ClientPersistedProperty]
public string DisabledCssClass { get; set; }
By default the visual appearance of disabled nodes is defined in the skin CSS file. You can use the DisabledCssClass property to specify unique appearance for a node when it is disabled.
Gets or sets a value specifying the URL of the image rendered when the node is disabled.
[ClientPersistedProperty]
public string DisabledImageUrl { get; set; }
If the
DisabledImageUrlproperty is not set the ImageUrl property will be used when the node is disabled.
Gets or sets a value indicating whether a context menu should be displayed for the current node.
[ClientPersistedProperty]
public bool EnableContextMenu { get; set; }
True if a context menu should be displayed for the current node; otherwise false. The default
value is false.
Use the EnableContextMenu property to disable the context menu for particular nodes.
Gets or sets a value indicating whether the node is enabled.
[ClientPersistedProperty]
public override bool Enabled { get; set; }
true if the node is enabled; otherwise false. The default value is true.
Overrides:
Disabled nodes cannot be clicked, or expanded.
Gets or sets a value indicating whether the node is expanded.
public bool Expanded { get; set; }
true if the node is expanded; otherwise, false. The default is false.
Gets or sets a value specifying the URL of the image rendered when the node is expanded.
[ClientPersistedProperty]
public string ExpandedImageUrl { get; set; }
If the
ExpandedImageUrlproperty is not set the ImageUrl property will be used when the node is expanded.
Gets or sets the expand behavior of the tree node.
When set to ExpandMode.ServerSide the RadTreeView will fire a server event (NodeExpand) so you can populate the node on demand.
[ClientPersistedProperty]
public TreeNodeExpandMode ExpandMode { get; set; }
On of the TreeNodeExpandMode values. The default value is
ClientSide.
Gets the full path (location) of the node.
[Browsable(false)]
public string FullPath { get; }
A slash delimited path of the node. The path is constructed based on the Text property of the node and its parents. For example if the Text of the node it "Houston", its parent node is "Texas" and its parent (root) is "U.S.A", FullPath will return "U.S.A/Texas/Houston"
Gets or sets the Cascading Style Sheet (CSS) class applied to the node when the mouse hovers it.
[ClientPersistedProperty]
public string HoveredCssClass { get; set; }
By default the visual appearance of hovered nodes is defined in the skin CSS file. You can use the HoveredCssClass property to specify unique appearance for a node when it is hoevered.
Gets or sets a value specifying the URL of the image rendered when the node is hovered with the mouse.
[ClientPersistedProperty]
public override string HoveredImageUrl { get; set; }
Overrides:
If the
HoveredImageUrlproperty is not set the ImageUrl property will be used when the node is hovered.
Gets or sets the URL to an image which is displayed next to the text of a node.
[ClientPersistedProperty]
public override string ImageUrl { get; set; }
The URL to the image to display for the node. The default value is empty string which means by default no image is displayed.
Overrides:
Use the ImageUrl property to specify a custom image that will be displayed before the text of the current node.
Gets the level of the node.
[Browsable(false)]
public int Level { get; }
An integer representing the level of the node. Root nodes are level 0 (zero).
Gets or sets the URL to navigate to when the current node is clicked.
[ClientPersistedProperty]
public override string NavigateUrl { get; set; }
The URL to navigate to when the node is clicked. The default value is empty string which means that clicking the current node will not navigate.
Overrides:
Setting the NavigateUrl property will disable node selection and as a result the NodeClick event won't be raised for the current node.
Gets the next sibling of the node.
[Browsable(false)]
public RadTreeNode Next { get; }
The next sibling of the node or null (Nothing) if the node is last in its parent RadTreeNodeCollection.
Gets a RadTreeNodeCollection object that contains the child nodes of the current RadTreeNode.
[Browsable(false)]
[PersistenceMode(PersistenceMode.InnerProperty)]
public RadTreeNodeCollection Nodes { get; }
A RadTreeNodeCollection that contains the child nodes of the current RadTreeNode. By default the collection is empty (the node has no children).
Implements:
Use the Nodes property to access the child nodes of the RadTreeNode. You can also use the Nodes property to manage the child nodes - you can add, remove or modify nodes.
Gets or sets the template for displaying the node.
[TemplateContainer(typeof(RadTreeNode))]
[PersistenceMode(PersistenceMode.InnerProperty)]
[Browsable(false)]
[Bindable(false)]
public ITemplate NodeTemplate { get; set; }
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.
To specify common display for all nodes use the NodeTemplate property of the RadTreeView control.
Gets the parent IRadTreeNodeContainer.
[Browsable(false)]
public IRadTreeNodeContainer Owner { get; }
Implements:
Gets the parent node of the current node.
[Browsable(false)]
public RadTreeNode ParentNode { get; }
The parent node. If the the node is a root node null (Nothing) is returned.
Gets or sets a value indicating whether clicking on the node will postback.
[ClientPersistedProperty]
public bool PostBack { get; set; }
True if the node should postback; otherwise false.
If you subscribe to the NodeClick all nodes will postback. To turn off that behavior you can set the PostBack property to false.
Gets the previous sibling of the node. Gets the previous node sibling in the tree structure or returns null if this is the first node in the respective node group.
[Browsable(false)]
public RadTreeNode Prev { get; }
The previous sibling of the node or null (Nothing) if the node is first in its parent RadTreeNodeCollection.
protected override IDictionary<string, string> PropertyMappings { get; }
Overrides:
Gets or sets a value indicating whether the node is selected.
public bool Selected { get; set; }
True if the node is selected; otherwise false. The default value is
false.
By default, only one node can be selected. You can enable multiple node selection by setting the MultipleSelect property of the parent RadTreeView to
true
Gets or sets the Cascading Style Sheet (CSS) class applied when node is selected.
[ClientPersistedProperty]
public string SelectedCssClass { get; set; }
By default the visual appearance of selected nodes is defined in the skin CSS file. You can use the SelectedCssClass property to specify unique appearance for a node when it is selected.
Gets or sets a value specifying the URL of the image rendered when the node is selected.
[ClientPersistedProperty]
public string SelectedImageUrl { get; set; }
If the
SelectedImageUrlproperty is not set the ImageUrl property will be used when the node is selected.
protected override HtmlTextWriterTag TagKey { get; }
Overrides:
Gets or sets the target window or frame in which to display the Web page content associated with the current node.
[TypeConverter(typeof(TargetConverter))]
[ClientPersistedProperty]
public override string Target { get; set; }
The target window or frame to load the Web page linked to when the node is clicked. Values must begin with a letter in the range of a through z (case insensitive), except for the following special values, which begin with an underscore:
| _blank | Renders the content in a new window without frames. |
| _parent | Renders the content in the immediate frameset parent. |
| _self | Renders the content in the frame with focus. |
| _top | Renders the content in the full window without frames. |
The default value is empty string which means the linked resource will be loaded in the current window.
Overrides:
Use the Target property to target window or frame in which to display the Web page content associated with the current node. The Web page is specified by the NavigateUrl property.
If this property is not set, the Web page specified by the NavigateUrl property is loaded in the current window.
The Target property is taken into consideration only when the NavigateUrl property is set.
Gets or sets the text displayed for the current node.
[ClientPersistedProperty]
public override string Text { get; set; }
The text displayed for the node in the RadTreeView control. The default is empty string.
Overrides:
Use the Text property to specify or determine the text that is displayed for the node in the RadTreeView control.
Gets or sets the tooltip shown for the node when the user hovers it with the mouse
[ClientPersistedProperty]
public override string ToolTip { get; set; }
A string representing the tooltip. The default value is empty string.
Overrides:
The ToolTip property is also used as the alt attribute of the node image (in case ImageUrl is set)
Gets the RadTreeView which the node is part of.
[Browsable(false)]
public RadTreeView TreeView { get; }
Gets or sets custom (user-defined) data associated with the current node.
[ClientPersistedProperty]
public override string Value { get; set; }
A string representing the user-defined data. The default value is emptry string.
Overrides:
Use the Value property to associate custom data with a RadTreeNode object.
Methods
protected override void AddAttributesToRender(HtmlTextWriter writer)
Overrides:
Checks all child nodes of the current node.
public void CheckChildNodes()
Creates a copy of the current RadTreeNode object.
public RadTreeNode Clone()
A RadTreeNode which is a copy of the current one.
Use the Clone method to create a copy of the current node. All properties of the clone are set to the same values as the current ones. Child nodes are copied as well.
Collapses recursively all child nodes of the node.
public void CollapseChildNodes()
Expands all parent nodes of the node.
public void CollapseParentNodes()
protected override ControlItemCollection CreateChildItemCollection()
Overrides:
Expands all child nodes of the node.
public void ExpandChildNodes()
Expands all parent nodes of the node.
public void ExpandParentNodes()
Gets a linear list of all nodes in the RadTreeNode.
public IList<RadTreeNode> GetAllNodes()
An IList<T> containing all nodes (from all hierarchy levels).
Inserts a node after the current node.
Inserts a node before the current node.
Checks if the current node is ancestor of another node.
public bool IsAncestorOf(RadTreeNode node)
The node to check for.
Returns:True if the current node is ancestor of the other node; otherwise false.
Checks if the current node is descendant of another node node.
public bool IsDescendantOf(RadTreeNode node)
The node to check for.
Returns:True if the current node is descendant of the other node; otherwise false.
protected override void LoadFromDictionary(IDictionary<string, object> dictionary)
Overrides:
Removes the node from the Nodes collection of its parent
public void Remove()
protected override void RenderContents(HtmlTextWriter writer)
Overrides:
protected override void SetItemContainer(ControlItemContainer itemContainer)
Overrides:
Toggles Expand/Collapse state of the node.
public void Toggle()
Unchecks all child nodes of the current node.
public void UncheckChildNodes()