Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

DxTreeList.HasChildrenFieldName Property

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

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
[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