Skip to main content
All docs
V24.2

DxTreeList.ParentKeyFieldName Property

Specifies the field that links a node to its parent.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

Declaration

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

Property Value

Type Default Description
String null

The name of the data field that stores parent node keys. This field’s value is 0 or null for root nodes.

Remarks

Assign a data source to the Data parameter to bind the TreeList component to data. To build a hierarchical structure of TreeList nodes, specify additional properties that define node relationships:

KeyFieldName
A field that contains unique identifiers for nodes.
ParentKeyFieldName
A field that contains parent node identifiers.

To bind the TreeList component to server-side data, you should also specify the HasChildrenFieldName property. Refer to the following topic for more information: Bind Blazor TreeList to Data.

To identify root nodes, the TreeList checks whether a node’s parent identifier matches RootValue. If the RootValue property is not specified (set to null), the TreeList component identifies root nodes as follows:

Flat Data Sources
When bound to flat data, a root node’s parent identifier does not point to any node.
Server-Side Data Sources

When bound to server-side data, the parent identifier of root nodes matches one of the following values:

The TreeList component does not display a node if its parent identifier does not point to any node.

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 and specifies node hierarchy settings:

@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

Implements

See Also