DxTreeList.EmptyDataAreaTemplate Property
Specifies the template used to display an empty data area.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v24.2.dll
NuGet Package: DevExpress.Blazor
Declaration
[Parameter]
public RenderFragment<TreeListEmptyDataAreaTemplateContext> EmptyDataAreaTemplate { get; set; }
Property Value
Type | Description |
---|---|
RenderFragment<TreeListEmptyDataAreaTemplateContext> | Template content. |
Remarks
The TreeList displays an empty data area in the following cases:
- The Data property is unset or equals
null
. - The TreeList is bound to an empty data source.
- The TreeList sends the first request to a remote data source and waits for a response.
- None of the TreeList data items matches the current filter criteria.
Define the EmptyDataAreaTemplate
to customize content displayed in the empty data area. If you add only inline HTML elements to the template, the TreeList applies default style settings of the empty data area to the template content.
The template context parameter includes the TreeList property. This property allows you to access the TreeList component and use its extensive API to identify the current component state. In the following code snippet, the empty data area displays different text strings based on the TreeList state:
@inject EmployeeTaskService EmployeeTaskService
<DxTreeList Data="TreeListData" KeyFieldName="Id" ParentKeyFieldName="ParentId" ShowFilterRow="true">
<Columns>
<DxTreeListDataColumn FieldName="Name" Caption="Task" />
<DxTreeListDataColumn FieldName="EmployeeName" />
<DxTreeListDataColumn FieldName="StartDate" />
<DxTreeListDataColumn FieldName="DueDate" />
</Columns>
<EmptyDataAreaTemplate>
<b>@GetEmptyDataAreaMessage(context.TreeList)</b>
</EmptyDataAreaTemplate>
</DxTreeList>
@code {
List<EmployeeTask> TreeListData { get; set; }
protected override void OnInitialized() {
TreeListData = EmployeeTaskService.GenerateData();
}
string GetEmptyDataAreaMessage(ITreeList treelist) {
var hasFilter = !object.ReferenceEquals(treelist.GetFilterCriteria(), null);
var waitingForData = !treelist.WaitForDataLoadAsync().IsCompleted;
if (treelist.Data == null) // Checks whether the TreeList contains data
return "Please configure your treelist";
if (waitingForData) // Checks whether data is loading
return "Loading data...";
if ((treelist.Data as IEnumerable<object>).Count() == 0)
return "The data source is empty.";
if (hasFilter) // Checks whether all items are hidden by the filter
return "No items match your search.";
return "No data to display";
}
}