Skip to main content

DxTreeViewDataMappingBase.HasChildren Property

Specifies whether a node has child nodes. Map this property to a data source field.

Namespace: DevExpress.Blazor.Base

Assembly: DevExpress.Blazor.v22.1.dll

Declaration

[Parameter]
public string HasChildren { get; set; }

Property Value

Type Description
String

The field name.

Remarks

The HasChildren property is required when you enable the Load Child Nodes on Demand mode. This property specifies whether a TreeView node has child nodes. The component uses the HasChildren property value to render nodes before they are expanded for the first time. If you do not specify this property, users do not see TreeView child nodes in the UI.

<DxTreeView @ref="@treeView"
            CssClass="cw-480"
            Data="@DataSource"
            LoadChildNodesOnDemand="true">
    <DataMappings>
        <DxTreeViewDataMapping HasChildren="HasSubGroups"
                               Children="SubGroups"
                               Text="Title"/>
    </DataMappings>
</DxTreeView>

@code {
    DxTreeView treeView;

    IEnumerable<DateTimeGroup> DataSource = new List<DateTimeGroup>() {
        new DateTimeGroup(new DateTime(DateTime.Now.Year, 1, 1), DateTimeGroupType.Year)
    };

    protected override void OnAfterRender(bool firstRender) {
        if(firstRender) {
            var todayDate = DateTime.Now;
            treeView.SetNodeExpanded(n => n.Text == todayDate.Year.ToString(), true);
        }
        base.OnAfterRender(firstRender);
    }
}

Run Demo: TreeView - Load Child Nodes on Demand Mode

See Also