DxTreeList.RootValue Property
Specifies the value that root nodes contain in the field assigned to the ParentKeyFieldName property.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v24.2.dll
NuGet Package: DevExpress.Blazor
Declaration
[DefaultValue(null)]
[Parameter]
public object RootValue { get; set; }
Property Value
Type | Default | Description |
---|---|---|
Object | null | The parent identifier of root nodes. |
Remarks
When you bind the TreeList component to flat or server-side data, the component builds a hierarchical structure of TreeList nodes based on the following properties:
- KeyFieldName
- A field name that contains node unique identifiers.
- ParentKeyFieldName
- A field name that contains a node’s parent identifier.
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:
null
for nullable data types0
for numeric data types- Guid.Empty for the Guid type
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. In this data source, the parent identifier of root nodes is -1
:
@inject EmployeeTaskService EmployeeTaskService
<DxTreeList Data="TreeListData" KeyFieldName="Id" ParentKeyFieldName="ParentId" RootValue="@MyRootValue">
<Columns>
<DxTreeListDataColumn FieldName="Name" Caption="Task" />
<DxTreeListDataColumn FieldName="EmployeeName" />
<DxTreeListDataColumn FieldName="StartDate" />
<DxTreeListDataColumn FieldName="DueDate" />
</Columns>
</DxTreeList>
@code {
object MyRootValue = -1;
List<EmployeeTask> TreeListData { get; set; }
protected override void OnInitialized() {
TreeListData = EmployeeTaskService.GenerateData();
}
}
Refer to the following topic for more information: Bind Blazor TreeList to Data.