Skip to main content
All docs
V24.1

DxTreeList.KeyFieldName Property

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

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.1.dll

NuGet Package: DevExpress.Blazor

Declaration

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

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