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.KeyFieldName Property

Specifies the field name that contains unique identifiers for TreeList nodes.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
[DefaultValue(null)]
[Parameter]
public string KeyFieldName { get; set; }

#Property Value

Type Default Description
String null

The key field’s name.

#Remarks

The TreeList component uses the key field’s values to identify and compare data items. The KeyFieldName property is optional when you bind the TreeList component to hierarchical data with ChildrenFieldName property, ChildrenLoading event, or ChildrenLoadingOnDemand event. If you do not specify the key field, the TreeList uses standard .NET value equality comparison to identify and compare data items.

In other data binding scenarios, the KeyFieldName property is required. An exception occurs if you do not specify this property.

Note

Data types of RootValue and data source fields assigned to KeyFieldName and ParentKeyFieldName properties should match.

The following example binds the TreeList component to a flat data source:

@inject EmployeeTaskService EmployeeTaskService

<DxTreeList Data="TreeListData" KeyFieldName="Id" ParentKeyFieldName="ParentId">
    <Columns>
        <DxTreeListDataColumn FieldName="Name" Caption="Task" />
        <DxTreeListDataColumn FieldName="EmployeeName" />
        <DxTreeListDataColumn FieldName="StartDate" />
        <DxTreeListDataColumn FieldName="DueDate" />
    </Columns>
</DxTreeList>

@code {
    List<EmployeeTask> TreeListData { get; set; }

    protected override void OnInitialized() {
        TreeListData = EmployeeTaskService.GenerateData();
    }
}

Bind Blazor TreeList to Flat Data

Run Demo: Flat Data Read Tutorial: Bind Blazor TreeList to Data

See Also