• Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
Class SfTreeView<TValue> - Blazor API Reference | Syncfusion

    Show / Hide Table of Contents

    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.

    Inheritance
    System.Object
    SfBaseComponent
    SfTreeView<TValue>
    Inherited Members
    SfBaseComponent.Dispose()
    SfBaseComponent.Dispose(Boolean)
    SfBaseComponent.OnObservableChange(String, Object, Boolean, NotifyCollectionChangedEventArgs)
    Namespace: Syncfusion.Blazor.Navigations
    Assembly: Syncfusion.Blazor.dll
    Syntax
    public class SfTreeView<TValue> : SfBaseComponent, ITreeView
    Type Parameters
    NameDescription
    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 indicating whether the SfTreeView<TValue> allows nodes to be reordered using drag and drop.

    Declaration
    public bool AllowDragAndDrop { get; set; }
    Property Value
    TypeDescription
    System.Boolean

    true if drag and drop is allowed; otherwise, false. The default value is false.

    Remarks

    On desktop devices, nodes can be reordered by clicking and dragging them to the target position and releasing the mouse. On touch devices, nodes can be reordered using touch start, touch move, and touch end events.

    AllowEditing

    Gets or sets a value indicating whether node text can be edited by pressing the F2 key or double-clicking a SfTreeView<TValue> node.

    Declaration
    public bool AllowEditing { get; set; }
    Property Value
    TypeDescription
    System.Boolean

    true if editing is allowed; otherwise, false. The default value is false.

    Remarks

    When AllowEditing is set to true, the TreeView allows editing a node by double-clicking it or pressing the F2 key while the node is selected.
    When set to false, the TreeView allows the node text to be read-only.

    AllowMultiSelection

    Gets or sets a value indicating whether multi-selection of nodes is enabled in the SfTreeView<TValue> component.

    Declaration
    public bool AllowMultiSelection { get; set; }
    Property Value
    TypeDescription
    System.Boolean

    true if multi-selection is enabled; otherwise, false.

    Remarks

    When multi-selection is enabled, users can select multiple nodes in the SfTreeView<TValue> component 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 indicating whether the text of nodes in the SfTreeView<TValue> component is allowed to wrap to the next line when it exceeds the width of the node.

    Declaration
    public bool AllowTextWrap { get; set; }
    Property Value
    TypeDescription
    System.Boolean

    true if text wrapping is enabled; otherwise, false.

    Remarks

    When the AllowTextWrap property is set to true, the text of nodes in the SfTreeView<TValue> component 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 indicating whether the checked state of parent nodes in the SfTreeView<TValue> component
    is automatically updated based on the checked state of their child nodes.

    Declaration
    public bool AutoCheck { get; set; }
    Property Value
    TypeDescription
    System.Boolean

    true if the automatic update of parent node checked states is enabled; otherwise, false.

    Remarks

    When the AutoCheck property is set to true, the checked state of parent nodes in the SfTreeView<TValue> component 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> component.

    Declaration
    public string[] CheckedNodes { get; set; }
    Property Value
    TypeDescription
    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> component. By passing a collection of node IDs to this 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

    Triggers an event callback when the checked state of the node's checkbox has changed in the SfTreeView<TValue> component.

    Declaration
    public EventCallback<string[]> CheckedNodesChanged { get; set; }
    Property Value
    TypeDescription
    Microsoft.AspNetCore.Components.EventCallback<System.String[]>

    An event callback function.

    CssClass

    Gets or sets one or more CSS classes that customize the appearance of the SfTreeView<TValue> component.

    Declaration
    public string CssClass { get; set; }
    Property Value
    TypeDescription
    System.String

    A string containing one or more CSS class names separated by spaces. The default value is String.Empty.

    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> component.

    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,
                ParentId = 14,
                Name = "Gospel"
            });
            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;
        }
        .e-custom.e-treeview .e-fullrow {
            height: 200px;
        }
    </style>

    Disabled

    Gets or sets a value indicating whether the SfTreeView<TValue> component is enabled or disabled.

    Declaration
    public bool Disabled { get; set; }
    Property Value
    TypeDescription
    System.Boolean

    true if the TreeView component is disabled; otherwise, false. The default value is false.

    Remarks

    When set to true, user interaction with the TreeView component, including 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:

    @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 element where the draggable node can be moved and dropped.

    Declaration
    public string DropArea { get; set; }
    Property Value
    TypeDescription
    System.String

    A string representing the ID or CSS class of the target element.

    Remarks

    By default, the draggable element can be moved within the TreeView component. 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 a value indicating whether to persist the state of the SfTreeView<TValue> component between page reloads.

    Declaration
    public bool EnablePersistence { get; set; }
    Property Value
    TypeDescription
    System.Boolean

    true if state persistence is enabled; otherwise, false. The default value is false.

    Remarks

    When state persistence is enabled, the following properties will be stored in the browser's local storage to retain the state of the component after a page reload:

    1. SelectedNodesThe nodes that are selected in the TreeView component.
    2. CheckedNodesThe nodes that are checked in the TreeView component.
    3. ExpandedNodesThe nodes that are expanded in the TreeView component.

    EnableRtl

    Gets or sets a value indicating whether right-to-left (RTL) rendering is enabled for the SfTreeView<TValue> component.

    Declaration
    public bool EnableRtl { get; set; }
    Property Value
    TypeDescription
    System.Boolean

    true if the right-to-left direction is enabled for the SfTreeView<TValue> component; otherwise, false. The default value is false.

    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 SfTreeView<TValue> component, which loads data on-demand through vertical scrolling.

    Declaration
    public bool EnableVirtualization { get; set; }
    Property Value
    TypeDescription
    System.Boolean

    true to enable virtualization in the TreeView; otherwise, false. The default value is false.

    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.
    Note:

    • Virtualization is not compatible with expand and collapse animation.
    • The Height property of the TreeView must be set to use this virtualization feature.
    • The "Select All" action will only select visible items in the UI.

    ExpandedNodes

    Gets or sets the IDs of expanded nodes in the SfTreeView<TValue> component.

    Declaration
    public string[] ExpandedNodes { get; set; }
    Property Value
    TypeDescription
    System.String[]

    Pass the node's ID as a string array collection.

    Remarks

    This property is used to track which nodes are currently expanded in the TreeView, allowing users to retain their expanded view even after the application is closed and reopened. This property supports two-way binding, ensuring that any changes 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 IDs of the expanded nodes.
    • The MusicAlbum class defines the data structure of each node in the tree.
    • 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 receives 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
    TypeDescription
    Microsoft.AspNetCore.Components.EventCallback<System.String[]>

    An event callback function.

    ExpandOn

    Gets or sets the action that triggers the expand or collapse operation for nodes in the SfTreeView<TValue> component.

    Declaration
    public ExpandAction ExpandOn { get; set; }
    Property Value
    TypeDescription
    ExpandAction

    The default value is DoubleClick.

    Remarks

    The available actions are:

    • Click – The expand/collapse operation happens when you single-click on the node on desktop.
    • DoubleClick – The expand/collapse operation happens when you double-click on the node on desktop.
    • None – The expand/collapse operation is disabled. In mobile devices, the node expand/collapse action always happens on a single tap.
    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,
               ParentId = 14,
               Name = "Gospel"
           });
           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 indicating whether the entire SfTreeView<TValue> node is navigable instead of just the text element.

    Declaration
    public bool FullRowNavigable { get; set; }
    Property Value
    TypeDescription
    System.Boolean

    true if the entire TreeView node is 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 indicating whether the entire row of the SfTreeView<TValue> node is selected when clicked.

    Declaration
    public bool FullRowSelect { get; set; }
    Property Value
    TypeDescription
    System.Boolean

    true if the entire node is selected 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. If set to false, only the text section of the node will be selectable.

    Height

    Gets or sets the scrollable height of the SfTreeView<TValue> component.

    Declaration
    public string Height { get; set; }
    Property Value
    TypeDescription
    System.String

    The height value, defined in pixels by the user, to be applied to the TreeView container.

    Remarks

    The TreeView will render within the container based on the specified height. Scrolling will occur based on this height, and the virtualization feature will operate according to this value.

    ID

    Gets or sets the ID attribute for the SfTreeView<TValue> component.

    Declaration
    public string ID { get; set; }
    Property Value
    TypeDescription
    System.String

    A string value representing the ID of the TreeView component.

    LoadOnDemand

    Gets or sets a value that indicates whether child nodes will be rendered dynamically when expanding or collapsing a parent node, instead of loading all tree nodes initially in the SfTreeView<TValue> component.

    Declaration
    public bool LoadOnDemand { get; set; }
    Property Value
    TypeDescription
    System.Boolean

    Set to true to load child nodes dynamically when 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 improves the performance of the SfTreeView<TValue> component on initial load by loading only parent nodes initially. If this property is set to false, all parent and child nodes are rendered on initial load, which may impact performance for large data sets.

    SelectedNodes

    Gets or sets the IDs of the selected nodes in the SfTreeView<TValue> component.

    Declaration
    public string[] SelectedNodes { get; set; }
    Property Value
    TypeDescription
    System.String[]

    Pass the node's ID as a string array collection.

    Remarks

    The SelectedNodes property supports two-way binding. Changes to the selected nodes in the TreeView will be reflected in the bound string array collection. This property allows you to track and manage the selected state of nodes in the TreeView component.

    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 receives an array of strings containing the IDs of the nodes whose selected state has changed. This allows updating the application state or performing other actions in response to node selection changes.

    Declaration
    public EventCallback<string[]> SelectedNodesChanged { get; set; }
    Property Value
    TypeDescription
    Microsoft.AspNetCore.Components.EventCallback<System.String[]>

    An event callback function.

    ShowCheckBox

    Gets or sets a value indicating whether to display checkboxes for each node in the SfTreeView<TValue> component.

    Declaration
    public bool ShowCheckBox { get; set; }
    Property Value
    TypeDescription
    System.Boolean

    Set to true to show checkboxes next to each tree view node; otherwise, false. The default value is false.

    Remarks

    The ShowCheckBox property controls the visibility of checkboxes in tree nodes. The checkboxes support tri-state behavior: checked, unchecked, and indeterminate.
    Checking or unchecking can be done by clicking the checkbox or pressing the space key.
    The checkboxes are displayed next to the node's expand/collapse icon.

    SortComparer

    Gets or sets a custom sort comparer object to define a custom sorting logic.

    Declaration
    public IComparer<object> SortComparer { get; set; }
    Property Value
    TypeDescription
    System.Collections.Generic.IComparer<System.Object>

    Name of sort comparer object to be executed. The default value is null.

    Remarks

    To define custom sorting logic, implement the comparer class using the IComparer interface.
    This allows overriding the default sorting behavior of the SfTreeView<TValue> component.

    SortOrder

    Gets or sets the sort order for the nodes in the SfTreeView<TValue> component.

    Declaration
    public SortOrder SortOrder { get; set; }
    Property Value
    TypeDescription
    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 a collection of TreeView nodes at the specified target and index position. If the target node is not specified, then the nodes are added as children of the given parentID or at the root level of the TreeView.

    Declaration
    public void AddNodes(List<TValue> nodes, string target = null)
    Parameters
    TypeNameDescription
    System.Collections.Generic.List<TValue>nodes

    A list of nodes to be added to the TreeView.

    System.Stringtarget

    Specifies the target to which the nodes will be added as children of the given parentID or at the root level of the TreeView.

    BeginEditAsync(String)

    Enables editing of a TreeView node without clicking on it.
    Passing the node ID or element through this method will create an edit text box for the specified node, allowing it to be edited.

    Declaration
    public Task BeginEditAsync(string node)
    Parameters
    TypeNameDescription
    System.Stringnode

    Specifies the ID of the TreeView node to be edited.

    Returns
    TypeDescription
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task that represents any asynchronous action.

    BuildRenderTree(RenderTreeBuilder)

    Declaration
    protected override void BuildRenderTree(RenderTreeBuilder __builder)
    Parameters
    TypeNameDescription
    Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder__builder

    CheckAllAsync(String[])

    Checks all the unchecked nodes in the TreeView. Specific nodes can be checked by passing an array of unchecked node IDs as an argument to this method.

    Declaration
    public Task CheckAllAsync(string[] nodesId = null)
    Parameters
    TypeNameDescription
    System.String[]nodesId

    Specifies the IDs of the nodes to be checked. If not provided, all unchecked nodes will be checked.

    Returns
    TypeDescription
    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 dynamically changing the data source.

    Declaration
    public Task ClearStateAsync()
    Returns
    Type
    System.Threading.Tasks.Task

    CollapseAllAsync(String[])

    Collapses all the expanded nodes in the TreeView. Specific nodes can also be collapsed by passing an array of node IDs as an argument to this method.

    Declaration
    public Task CollapseAllAsync(string[] nodesId = null)
    Parameters
    TypeNameDescription
    System.String[]nodesId

    Specifies the NodeID to be collapsed. If not provided, all expanded nodes will be collapsed.

    Returns
    TypeDescription
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task that represents any asynchronous action.

    DisableNodesAsync(String[])

    Disables a collection of nodes by passing the ID of nodes or node elements in the array.

    Declaration
    public Task DisableNodesAsync(string[] nodes)
    Parameters
    TypeNameDescription
    System.String[]nodes

    Specifies the array of TreeView nodes ID to be disabled.

    Returns
    TypeDescription
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task that represents any asynchronous action.

    EnableNodesAsync(String[])

    Enables a collection of disabled nodes by passing the ID of nodes or node elements in the array.

    Declaration
    public Task EnableNodesAsync(string[] nodes)
    Parameters
    TypeNameDescription
    System.String[]nodes

    Specifies the array of TreeView nodes ID to be enabled.

    Returns
    TypeDescription
    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, EnsureVisibleAsync method brings the node to visibility by expanding the TreeView and scrolling to the specific node.

    Declaration
    public Task EnsureVisibleAsync(string node)
    Parameters
    TypeNameDescription
    System.Stringnode

    Specifies ID of TreeView node.

    Returns
    TypeDescription
    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 ID.

    Declaration
    public Task ExpandAllAsync(string[] nodesId = null)
    Parameters
    TypeNameDescription
    System.String[]nodesId

    Specifies the NodeId.

    Returns
    TypeDescription
    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
    TypeNameDescription
    System.BooleanincludeInterMediate

    Set to true or false to include intermediate node details.

    Returns
    TypeDescription
    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
    TypeDescription
    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
    TypeNameDescription
    System.Stringnode

    Specifies ID of TreeView node.

    Returns
    TypeDescription
    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
    TypeNameDescription
    System.Stringnode

    Specifies ID of TreeView node.

    Returns
    TypeDescription
    System.Collections.Generic.List<TValue>

    Return TreeData.

    OnAfterRenderAsync(Boolean)

    Method invoked after each time the component has been rendered.

    Declaration
    protected override Task OnAfterRenderAsync(bool firstRender)
    Parameters
    TypeNameDescription
    System.BooleanfirstRender

    Set to true for the first time component rendering; otherwise gets false.

    Returns
    TypeDescription
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task representing any asynchronous operation.

    Overrides
    SfBaseComponent.OnAfterRenderAsync(Boolean)

    OnInitializedAsync()

    Method invoked when the component is ready to start.

    Declaration
    protected override Task OnInitializedAsync()
    Returns
    TypeDescription
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task representing any asynchronous operation.

    Overrides
    SfBaseComponent.OnInitializedAsync()

    OnParametersSetAsync()

    Declaration
    protected override Task OnParametersSetAsync()
    Returns
    Type
    System.Threading.Tasks.Task

    PreventRender(Boolean)

    Declaration
    public void PreventRender(bool preventRender = true)
    Parameters
    TypeNameDescription
    System.BooleanpreventRender

    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
    TypeNameDescription
    System.Stringtarget

    Specifies the ID of TreeView node to be refreshed.

    System.Collections.Generic.List<TValue>newData

    Specifies the new Data of TreeView node.

    Returns
    TypeDescription
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task that represents any asynchronous action.

    RemoveNodes(String[])

    Removes a collection of TreeView nodes by passing an array of node details as an argument to this method.

    Declaration
    public void RemoveNodes(string[] nodes)
    Parameters
    TypeNameDescription
    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 an argument to this method.

    Declaration
    public Task UncheckAllAsync(string[] nodesId = null)
    Parameters
    TypeNameDescription
    System.String[]nodesId

    Specifies the Id of the node to be unchecked.

    Returns
    TypeDescription
    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
    TypeNameDescription
    TreeViewNodeAnimationSettingsanimationSettings

    "Specifies the animation settings".

    UpdateChildProperties(String, Object)

    Update child property values in the TreeView component instance.

    Declaration
    public void UpdateChildProperties(string key, object details)
    Parameters
    TypeNameDescription
    System.Stringkey

    Specifies the key field.

    System.Objectdetails

    Specifies the details field.

      Back to top Generated by DocFX
      Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved