Skip to main content
All docs
V24.1

DxTreeList.HasChildrenFieldName Property

Specifies the field name that defines whether a node has children.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.1.dll

NuGet Package: DevExpress.Blazor

Declaration

[DefaultValue(null)]
[Parameter]
public string HasChildrenFieldName { get; set; }

Property Value

Type Default Description
String null

The field name that defines whether a node has children.

Remarks

The TreeList component can initially load only root nodes. It can retrieve child nodes on demand when a user expands a parent node for the first time. Enable this behavior in one of the following ways:

In on-demand mode, the TreeList component uses the HasChildrenFieldName property to determine whether a node has children and requires an expand button. If you do not specify the HasChildrenFieldName property, the component throws an exception.

Read Tutorial: Bind Blazor TreeList to Data Run Demo: Large Dataset Run Demo: Load Data on Demand

The following code sample uses the Entity Framework Core data access technology to bind the TreeList component to the GridDevExtremeDataSource<T>:

@inject CitiesService CitiesService

<DxTreeList Data="@Data"
            KeyFieldName="ID"
            ParentKeyFieldName="ParentID" 
            HasChildrenFieldName="HasChildren">
    <Columns>
        <DxTreeListDataColumn Caption="Location" FieldName="Name" />
        <DxTreeListDataColumn FieldName="CityType" />
        <DxTreeListDataColumn FieldName="Year" DisplayFormat="d"/>
        <DxTreeListDataColumn FieldName="RecordType" />
        <DxTreeListDataColumn FieldName="Population" />
    </Columns>
</DxTreeList> 

@code {
    object Data { get; set; }

    protected override async Task OnInitializedAsync() {
        var cities = await CitiesService.GetCitiesAsync();
        Data = new GridDevExtremeDataSource<Location>(cities.AsQueryable());
    }
}

Bind Blazor TreeList to Server-Side Data

See Also