Class SfTreeView<TValue>
The Blazor TreeView component displays hierarchical data, such as a table of contents, code examples, and file directories, in a tree-like structure.
Inherited Members
Namespace: Syncfusion.Blazor.Navigations
Assembly: Syncfusion.Blazor.dll
Syntax
public class SfTreeView<TValue> : SfBaseComponent, ITreeView
Type Parameters
Name | Description |
---|---|
TValue | Specifies the type of data source. |
Remarks
The Blazor TreeView component offers various features for editing, load on demand, drag and drop, checkboxes, expand/collapse, and more in both Blazor WebAssembly (WASM) and Blazor Server apps.
Examples
Constructors
SfTreeView()
Declaration
public SfTreeView()
Properties
AllowDragAndDrop
Gets or sets a value that indicates whether the TreeView allows drag and drop of nodes for reordering.
Declaration
public bool AllowDragAndDrop { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Remarks
In desktop devices, drag and drop a node using the mouse by clicking on the node and dragging it to the target node, and then releasing the mouse. In touch devices, drag and drop nodes using touch start, touch move, and touch end events.
AllowEditing
Gets or sets whether allow to edit a node's text by pressing F2 key or double-click on a SfTreeView<TValue> node.
Declaration
public bool AllowEditing { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Remarks
When AllowEditing
property is set to true, the TreeView allows to edit a node
by double clicking on the node or by navigating to the node and pressing F2 key.
When the property is set to false, the TreeView allows to read the node text only.
AllowMultiSelection
Gets or sets a value that indicates whether multi-selection of nodes is enabled in the SfTreeView<TValue> control.
Declaration
public bool AllowMultiSelection { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Remarks
When multi-selection is enabled, users can select multiple nodes in the SfTreeView<TValue> control by holding down the CTRL key and clicking on the nodes they want to select. Consecutive nodes can be selected by holding down the SHIFT key and clicking on the initial and final nodes of the range to be selected. The ShowCheckBox property can also be used to enable checkbox support for node selection.
AllowTextWrap
Gets or sets a value that indicates whether the text of nodes in the SfTreeView<TValue> control is allowed to wrap to the next line when it exceeds the width of the node.
Declaration
public bool AllowTextWrap { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Remarks
When the AllowTextWrap
property is set to true
, the text of nodes in the SfTreeView<TValue> control
will wrap to the next line if its length exceeds the width of the node. This can be useful for displaying long
or multi-line text in the tree view without truncating or clipping it.
AutoCheck
Gets or sets a value that determines whether the checked state of parent nodes in the SfTreeView<TValue> control is automatically updated based on the checked state of their child nodes.
Declaration
public bool AutoCheck { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Remarks
When the AutoCheck
property is set to true
, the checked state of parent nodes in the SfTreeView<TValue> control
will be automatically updated based on the checked state of their child nodes. This can be useful for maintaining the
consistency of the tree view's checkbox hierarchy and ensuring that parent nodes are only checked if all of their child
nodes are also checked. This property only works when the ShowCheckBox
property is set to true
.
CheckedNodes
Gets or sets the IDs of the nodes that are checked in the SfTreeView<TValue> control.
Declaration
public string[] CheckedNodes { get; set; }
Property Value
Type | Description |
---|---|
System.String[] | A collection of strings containing the IDs of the nodes that are checked in the tree view. |
Remarks
The CheckedNodes
property supports two-way binding in the SfTreeView<TValue> control.
By passing a collection of node IDs to the property, the checked state of the specified nodes can be set.
The property can also be used to retrieve the IDs of the nodes that are currently checked in the tree view.
Examples
<SfTreeView TValue="MusicAlbum" ShowCheckBox="true" @bind-CheckedNodes="@CheckedNodes">
<TreeViewFieldsSettings TValue="MusicAlbum" Id="Id" DataSource="@Albums" Text="Name" ParentID="ParentId" HasChildren="HasChild" Expanded="Expanded" IsChecked="IsChecked"></TreeViewFieldsSettings>
</SfTreeView>
@code{
string[] CheckedNodes = new string[] { "16","18" };
}
CheckedNodesChanged
Raised when the checked state of the node's checkbox has changed in the SfTreeView<TValue> control.
Declaration
public EventCallback<string[]> CheckedNodesChanged { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<System.String[]> | An event callback function. |
CssClass
Gets or sets one or more CSS classes that can be used to customize the appearance of the SfTreeView<TValue> control.
Declaration
public string CssClass { get; set; }
Property Value
Type | Description |
---|---|
System.String | A string containing one or more CSS class names separated by spaces. The default value is |
Remarks
When one or more CSS classes are set on the CssClass
property, the corresponding styles will be applied to the UI elements of the SfTreeView<TValue> control.
Examples
<SfTreeView TValue="MusicAlbum" CssClass="e-custom e-tree">
<TreeViewFieldsSettings TValue="MusicAlbum" Id="Id" DataSource="@Albums" Text="Name" ParentID="ParentId" HasChildren="HasChild" Expanded="Expanded" IsChecked="IsChecked"></TreeViewFieldsSettings>
</SfTreeView>
@code{
public class MusicAlbum
{
public int Id { get; set; }
public int? ParentId { get; set; }
public string Name { get; set; }
public bool Expanded { get; set; }
public bool? IsChecked { get; set; }
public bool HasChild { get; set; }
}
List<MusicAlbum> Albums = new List<MusicAlbum>();
protected override void OnInitialized()
{
base.OnInitialized();
Albums.Add(new MusicAlbum
{
Id = 14,
HasChild = true,
Name = "MP3 Albums",
Expanded = true
});
Albums.Add(new MusicAlbum
{
Id = 15,
ParentId = 14,
Name = "Rock"
});
Albums.Add(new MusicAlbum
{
Id = 16,
Name = "Gospel",
ParentId = 14,
});
Albums.Add(new MusicAlbum
{
Id = 17,
ParentId = 14,
Name = "Latin Music"
});
Albums.Add(new MusicAlbum
{
Id = 18,
ParentId = 14,
Name = "Jazz"
});
}
}
<style>
.e-custom .e-tree {
padding: 10px 0;
font-weight: 800;
}
.custom.e-treeview .e-fullrow {
height: 200px;
}
</style>
Disabled
Gets or sets a value that indicates whether to enable or disable the SfTreeView<TValue> component.
Declaration
public bool Disabled { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Remarks
When set to true, the user interaction with the TreeView and all its nodes and associated elements, such as checkboxes and icons, will be prevented. For example, to disable the SfTreeView<TValue> component when a button is clicked, you can use the following code:
@{ bool isTreeViewDisabled = false; void ToggleTreeViewDisabled() { isTreeViewDisabled = !isTreeViewDisabled; } } <SfTreeView TValue="MusicAlbum" Disabled="@isTreeViewDisabled"> ... </SfTreeView> <button @onclick="ToggleTreeViewDisabled">Toggle disabled state</button>
DropArea
Gets or sets the target in which the draggable node can be moved and dropped.
Declaration
public string DropArea { get; set; }
Property Value
Type | Description |
---|---|
System.String | Accepts the string value. |
Remarks
By default, the draggable element can be moved within the TreeView. To specify a different drop target,
set the DropArea
property to the ID or CSS class of the element that should act as the drop target.
Examples
<div class="treeParent">
<SfTreeView TValue="MusicAlbum" DropArea=".treeParent">
<TreeViewFieldsSettings TValue="MusicAlbum" Id="Id" DataSource="@Albums" Text="Name" ParentID="ParentId" HasChildren="HasChild" Expanded="Expanded" IsChecked="IsChecked"></TreeViewFieldsSettings>
</SfTreeView>
<div>
@code{
public class MusicAlbum
{
public int Id { get; set; }
public int? ParentId { get; set; }
public string Name { get; set; }
public bool Expanded { get; set; }
public bool? IsChecked { get; set; }
public bool HasChild { get; set; }
}
List<MusicAlbum> Albums = new List<MusicAlbum>();
protected override void OnInitialized()
{
base.OnInitialized();
Albums.Add(new MusicAlbum
{
Id = 14,
HasChild = true,
Name = "MP3 Albums",
Expanded = true
});
Albums.Add(new MusicAlbum
{
Id = 15,
ParentId = 14,
Name = "Rock"
});
}
}
EnablePersistence
Gets or sets whether to persist the state of the SfTreeView<TValue> component between page reloads.
Declaration
public bool EnablePersistence { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Remarks
The following properties will be stored in browser local storage to persist the state of the component when the page reloads:
- SelectedNodesThe nodes that are selected in the TreeView component.
- CheckedNodesThe nodes that are checked in the TreeView component.
- ExpandedNodesThe nodes that are expanded in the TreeView component.
EnableRtl
Gets or sets whether the right to left direction is enabled for the SfTreeView<TValue> component.
Declaration
public bool EnableRtl { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Remarks
When set to true
, the layout of the SfTreeView<TValue> component will be rendered from right to left.
EnableVirtualization
Gets or sets a value indicating whether virtualization is enabled in the TreeView which loads the data on-demand through vertical scrolling.
Declaration
public bool EnableVirtualization { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Remarks
When set to true
, virtualization is enabled, and the TreeView will load only the nodes that are currently visible in the viewport, which can significantly improve the performance and responsiveness of the TreeView when dealing with large datasets.
Subsequent nodes will be loaded dynamically as the user scrolls vertically through the TreeView.
Setting “Height” property of TreeView is necessary to use this virtualization feature.
ExpandedNodes
Gets or sets the ID of expanded nodes in the SfTreeView<TValue> component.
Declaration
public string[] ExpandedNodes { get; set; }
Property Value
Type | Description |
---|---|
System.String[] | Pass the node's ID as a string array collection. |
Remarks
This property is used to keep track of which nodes in the TreeView are currently expanded, allowing the user to retain their current view of the tree when the application is closed and reopened. This property supports two-way binding, so any changes made to the expanded nodes in the TreeView will be reflected in the bound string array collection.
Examples
<SfTreeView TValue="MusicAlbum" ShowCheckBox="true" @bind-ExpandedNodes="@ExpandedNodes">
<TreeViewFieldsSettings TValue="MusicAlbum" Id="Id" DataSource="@Albums" Text="Name" ParentID="ParentId" HasChildren="HasChild" Expanded="Expanded" IsChecked="IsChecked"></TreeViewFieldsSettings>
</SfTreeView>
@code{
public class MusicAlbum
{
public int Id { get; set; }
public int? ParentId { get; set; }
public string Name { get; set; }
public bool Expanded { get; set; }
public bool? IsChecked { get; set; }
public bool HasChild { get; set; }
}
string[] ExpandedNodes = new string[] { "16","18" };
List<MusicAlbum> Albums = new List<MusicAlbum>();
protected override void OnInitialized()
{
base.OnInitialized();
Albums.Add(new MusicAlbum
{
Id = 14,
HasChild = true,
Name = "MP3 Albums"
});
Albums.Add(new MusicAlbum
{
Id = 15,
ParentId = 14,
Name = "Rock"
});
}
}
In this example, the ExpandedNodes
property is bound to a string array containing the ID of the expanded nodes in the TreeView. The MusicAlbum
class is used to define the data structure of each node in the tree, and the Albums
list is populated with sample data in the OnInitialized
method. The ShowCheckBox
property is set to true
to enable checkboxes for each node.
ExpandedNodesChanged
This event is raised whenever the expanded state of a node in the SfTreeView<TValue> component changes. The callback will receive an array of strings containing the IDs of the nodes whose expanded state has changed. This can be used to update the application's state or perform other actions in response to changes in the expanded nodes.
Declaration
public EventCallback<string[]> ExpandedNodesChanged { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<System.String[]> | An event callback function. |
ExpandOn
Gets or sets the value that indicates the action on which the node expands or collapses in the SfTreeView<TValue> component.
Declaration
public ExpandAction ExpandOn { get; set; }
Property Value
Type | Description |
---|---|
ExpandAction | The default value is |
Remarks
The available actions are:
ExpandAction.Click
- The expand/collapse operation happens when you single-click on the node in desktop.ExpandAction.DblClick
- The expand/collapse operation happens when you double-click on the node in desktop.ExpandAction.None
- The expand/collapse operation will not happen. In mobile devices, the node expand/collapse action happens on single tap always.
Examples
<SfTreeView TValue="MusicAlbum" ExpandOn="ExpandAction.Click">
<TreeViewFieldsSettings TValue="MusicAlbum" Id="Id" DataSource="@Albums" Text="Name" ParentID="ParentId" HasChildren="HasChild" Expanded="Expanded" IsChecked="IsChecked"></TreeViewFieldsSettings>
</SfTreeView>
@code{
public class MusicAlbum
{
public int Id { get; set; }
public int? ParentId { get; set; }
public string Name { get; set; }
public bool Expanded { get; set; }
public bool? IsChecked { get; set; }
public bool HasChild { get; set; }
}
SfTreeView<MusicAlbum> tree;
List<MusicAlbum> Albums = new List<MusicAlbum>();
protected override void OnInitialized()
{
base.OnInitialized();
Albums.Add(new MusicAlbum
{
Id = 14,
HasChild = true,
Name = "MP3 Albums",
Expanded = true
});
Albums.Add(new MusicAlbum
{
Id = 15,
ParentId = 14,
Name = "Rock"
});
Albums.Add(new MusicAlbum
{
Id = 16,
Name = "Gospel",
ParentId = 14,
});
Albums.Add(new MusicAlbum
{
Id = 17,
ParentId = 14,
Name = "Latin Music"
});
Albums.Add(new MusicAlbum
{
Id = 18,
ParentId = 14,
Name = "Jazz"
});
}
}
FullRowNavigable
Gets or sets a value that indicates whether the entire SfTreeView<TValue> node will be navigable, instead of just the text element.
Declaration
public bool FullRowNavigable { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | Set to 'true' to make the entire TreeView node navigable; otherwise 'false'. The default value is 'false'. |
Remarks
When this property is set to 'true', navigation occurs when the user clicks on any part of the TreeView node. Otherwise, navigation occurs only when the user clicks on the text of the TreeView node.
FullRowSelect
Gets or sets a value that indicates whether the entire row of the SfTreeView<TValue> node gets selected by clicking a node.
Declaration
public bool FullRowSelect { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | Set to 'true' to select the entire node when clicked; otherwise, only the node's text section will be selected. The default value is 'true'. |
Remarks
If this property is set to 'true', the entire tree node will be selectable when clicked. Otherwise, only the text section of the node will be selected.
Height
Gets or sets the scrollable height of the TreeView content.
Declaration
public string Height { get; set; }
Property Value
Type | Description |
---|---|
System.String | The height value, defined in pixels by the user, will be set for the TreeView container. |
Remarks
The TreeView will render within the container based on the value specified with this property. Scrolling occurs based on this height, and the virtualization feature operates based on this property value.
ID
Gets or sets the ID attribute for the SfTreeView<TValue> element.
Declaration
public string ID { get; set; }
Property Value
Type | Description |
---|---|
System.String | A string value representing the ID of the TreeView element. |
LoadOnDemand
Gets or sets a value that indicates whether child nodes will be rendered while expanding and collapsing a parent node, instead of loading all tree nodes initially in the SfTreeView<TValue> component.
Declaration
public bool LoadOnDemand { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | Set to 'true' to load child nodes dynamically on expanding a parent node; otherwise, set to 'false'. The default value is 'true'. |
Remarks
By default, 'LoadOnDemand' is enabled, so child nodes are rendered dynamically when a parent node is expanded. This property can improve the performance of the SfTreeView<TValue> component on initial load, by only loading parent nodes initially. If this property is set to 'false', all parent and child nodes are rendered on initial load.
SelectedNodes
Gets or sets the ID of selected nodes in the SfTreeView<TValue> component.
Declaration
public string[] SelectedNodes { get; set; }
Property Value
Type | Description |
---|---|
System.String[] | Pass the node's ID as a string array collection. |
Remarks
The property SelectedNodes
supports two-way binding, so any changes made to the selected nodes in the TreeView
will be reflected in the bound string array collection. This property is used to keep track of which nodes in the TreeView are currently selected.
Examples
<SfTreeView TValue="MusicAlbum" @bind-SelectedNodes="@SelectedNodes">
<TreeViewFieldsSettings TValue="MusicAlbum" Id="Id" DataSource="@Albums" Text="Name" ParentID="ParentId" HasChildren="HasChild" Expanded="Expanded" IsChecked="IsChecked"></TreeViewFieldsSettings>
</SfTreeView>
@code{
public class MusicAlbum
{
public int Id { get; set; }
public int? ParentId { get; set; }
public string Name { get; set; }
public bool Expanded { get; set; }
public bool? IsChecked { get; set; }
public bool HasChild { get; set; }
}
string[] SelectedNodes = new string[] { "16","18" };
List<MusicAlbum> Albums = new List<MusicAlbum>();
protected override void OnInitialized()
{
base.OnInitialized();
Albums.Add(new MusicAlbum
{
Id = 14,
HasChild = true,
Name = "MP3 Albums"
});
Albums.Add(new MusicAlbum
{
Id = 15,
ParentId = 14,
Name = "Rock"
});
}
}
SelectedNodesChanged
This event is raised whenever the selected state of a node changes in the SfTreeView<TValue> component. The callback will receive an array of strings containing the IDs of the nodes whose selected state has changed. This can be used to update the application's state or perform other actions in response to changes in the selected nodes.
Declaration
public EventCallback<string[]> SelectedNodesChanged { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<System.String[]> | An event callback function. |
ShowCheckBox
Gets or sets a value that indicates whether to show checkboxes in each node of the SfTreeView<TValue> component.
Declaration
public bool ShowCheckBox { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | 'true' to show checkboxes on each tree view node; otherwise, 'false'. The default value is |
Remarks
The ShowCheckBox
property is used to show or hide the checkboxes in tree nodes. The checkboxes have tri-state behavior, such as checked, unchecked, and indeterminate.
The check/uncheck action can be performed either through checkbox click or pressing the space key.
The checkboxes are displayed next to the expand/collapse icon of the nodes.
SortComparer
Gets or sets the custom sort comparer object to implement own sorting logic.
Declaration
public IComparer<object> SortComparer { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IComparer<System.Object> | Name of sort comparer object to be executed. The default value is null. |
Remarks
Custom sort comparer class should be implemented in the interface IComparer. Custom sort comparer can be used to modify the default sorting logic.
SortOrder
Gets or sets the sort order for the nodes in the SfTreeView<TValue> component.
Declaration
public SortOrder SortOrder { get; set; }
Property Value
Type | Description |
---|---|
SortOrder | A value of the SortOrder enumeration. |
Remarks
The available options for the sort order are:
- None: The nodes are not sorted.
- Ascending: The nodes are sorted in ascending order.
- Descending: The nodes are sorted in descending order.
Methods
AddNodes(List<TValue>, String)
Adds the collection of TreeView nodes based on target and index position. If the target node is not specified, then the nodes are added as children of the given parentID or in the root level of TreeView.
Declaration
public void AddNodes(List<TValue> nodes, string target = null)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.List<TValue> | nodes | A list of nodes to be added to the TreeView. |
System.String | target | Specifies the target to which the nodes are added as children of the given parentID or in the root level of TreeView. |
BeginEditAsync(String)
Editing can also be enabled by using the BeginEditAsync
property, instead
of clicking on the TreeView node. On passing the node ID or element through this property, the edit textbox
will be created for the particular node thus allowing us to edit it.
Declaration
public Task BeginEditAsync(string node)
Parameters
Type | Name | Description |
---|---|---|
System.String | node | Specifies ID of TreeView node to be edited. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task that represents any asynchronous action |
BuildRenderTree(RenderTreeBuilder)
Declaration
protected override void BuildRenderTree(RenderTreeBuilder __builder)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder | __builder |
CheckAllAsync(String[])
Checks all the unchecked nodes. Specific nodes can also be checked by passing an array of unchecked nodes as argument to this method.
Declaration
public Task CheckAllAsync(string[] nodesId = null)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | nodesId | "Specifies the NodeId to be checked". |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task that represents any asynchronous action |
ClearStateAsync()
This method clears the Expanded, Selected and Checked interaction states in the TreeView. This method is useful when changing the data source dynamically.
Declaration
public Task ClearStateAsync()
Returns
Type |
---|
System.Threading.Tasks.Task |
CollapseAllAsync(String[])
Collapses all the expanded TreeView nodes. Specific nodes can be collapsed by passing an array of nodes as argument to this method.
Declaration
public Task CollapseAllAsync(string[] nodesId = null)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | nodesId | "Specifies the NodeID to be collapsed". |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task that represents any asynchronous action |
DisableNodesAsync(String[])
Disables the collection of nodes by passing the ID of nodes or node elements in the array.
Declaration
public Task DisableNodesAsync(string[] nodes)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | nodes | Specifies the array of TreeView nodes ID to be disabled. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task that represents any asynchronous action |
EnableNodesAsync(String[])
Enables the collection of disabled nodes by passing the ID of nodes or node elements in the array.
Declaration
public Task EnableNodesAsync(string[] nodes)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | nodes | Specifies the array of TreeView nodes ID to be enabled. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task that represents any asynchronous action |
EnsureVisibleAsync(String)
Ensures visibility of the TreeView node by using the node ID or node element.
When many TreeView nodes are present and a particular node has to be found, EnsureVisible
property
brings the node to visibility by expanding the TreeView and scrolling to the specific node.
Declaration
public Task EnsureVisibleAsync(string node)
Parameters
Type | Name | Description |
---|---|---|
System.String | node | Specifies ID of TreeView node. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task that represents any asynchronous action |
ExpandAllAsync(String[])
Expands all the collapsed TreeView nodes. Specific nodes can be expanded by passing the array of collapsed nodes.
Declaration
public Task ExpandAllAsync(string[] nodesId = null)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | nodesId | "Specifies the NodeId". |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task that represents any asynchronous action |
GetAllCheckedNodes(Boolean)
Gets all the checked nodes including intermediate nodes.
Declaration
public List<TValue> GetAllCheckedNodes(bool includeInterMediate)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | includeInterMediate | Set |
Returns
Type | Description |
---|---|
System.Collections.Generic.List<TValue> | Return all checked nodes. |
GetDisabledNodesAsync()
Gets all the disabled nodes including child, whether it is loaded or not.
Declaration
public Task<List<string>> GetDisabledNodesAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Collections.Generic.List<System.String>> | A System.Threading.Tasks.Task that represents any asynchronous action |
GetNode(String)
Get the node's data such as id, text, parentID, selected, isChecked, and expanded by passing the node element or it's ID.
Declaration
public NodeData GetNode(string node)
Parameters
Type | Name | Description |
---|---|---|
System.String | node | Specifies ID of TreeView node. |
Returns
Type | Description |
---|---|
NodeData | "Return TreeData". |
GetTreeData(String)
Gets the updated data source of TreeView after performing some operation like drag and drop, node editing, node selecting/unselecting, node expanding/collapsing, node checking/unchecking, adding and removing node. When the ID of TreeView node is passed as arguments for this method then it will return the updated data source of the corresponding node otherwise it will return the entire updated data source of TreeView. The updated data source also contains the custom attributes if specified in data source.
Declaration
public List<TValue> GetTreeData(string node = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | node | Specifies ID of TreeView node. |
Returns
Type | Description |
---|---|
System.Collections.Generic.List<TValue> | "Return TreeData". |
NodeCollapsingEventCallback(NodeExpandEventArgs, Boolean)
Triggers the NodeCollapsing Event callback
Declaration
public Task NodeCollapsingEventCallback(NodeExpandEventArgs args, bool fromClickHandler = false)
Parameters
Type | Name | Description |
---|---|---|
NodeExpandEventArgs | args | "NodeCollapsing event argument". |
System.Boolean | fromClickHandler | "Indicates whether the event is from click handler" |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | "Task" |
OnAfterRenderAsync(Boolean)
Method invoked after each time the component has been rendered.
Declaration
protected override Task OnAfterRenderAsync(bool firstRender)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | firstRender | Set to true for the first time component rendering; otherwise gets false. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task representing any asynchronous operation. |
Overrides
OnInitializedAsync()
Method invoked when the component is ready to start.
Declaration
protected override Task OnInitializedAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task representing any asynchronous operation. |
Overrides
OnParametersSetAsync()
Declaration
protected override Task OnParametersSetAsync()
Returns
Type |
---|
System.Threading.Tasks.Task |
PreventRender(Boolean)
Declaration
public void PreventRender(bool preventRender = true)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | preventRender |
RefreshNodeAsync(String, List<TValue>)
Replaces the text of the TreeView node with the given text.
Declaration
public Task RefreshNodeAsync(string target, List<TValue> newData)
Parameters
Type | Name | Description |
---|---|---|
System.String | target | Specifies the ID of TreeView node to be refreshed. |
System.Collections.Generic.List<TValue> | newData | Specifies the new Data of TreeView node. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task that represents any asynchronous action |
RemoveNodes(String[])
Removes the collection of TreeView nodes by passing the array of node details as argument to this method.
Declaration
public void RemoveNodes(string[] nodes)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | nodes | Specifies the array of TreeView nodes ID. |
ShouldRender()
Declaration
protected override bool ShouldRender()
Returns
Type |
---|
System.Boolean |
UncheckAllAsync(String[])
Unchecks all the checked nodes. Specific nodes can also be unchecked by passing array of checked nodes as argument to this method.
Declaration
public Task UncheckAllAsync(string[] nodesId = null)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | nodesId | "Specifies the Id of the node to be unchecked". |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task that represents any asynchronous action |
UpdateAnimationProperties(TreeViewNodeAnimationSettings)
Specifies the Animation properties.
Declaration
public void UpdateAnimationProperties(TreeViewNodeAnimationSettings animationSettings)
Parameters
Type | Name | Description |
---|---|---|
TreeViewNodeAnimationSettings | animationSettings | "Specifies the animation settings". |
UpdateChildProperties(String, Object)
Update child property values to TreeView component instance.
Declaration
public void UpdateChildProperties(string key, object details)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | "Specifies the key field". |
System.Object | details | "Specifies the details field". |