DxTreeList.Reload() Method
Reloads TreeList data.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v24.1.dll
NuGet Package: DevExpress.Blazor
Declaration
public void Reload()
Remarks
The TreeList component reloads its data automatically in response to the following actions:
- Observable Data Collection Notification
- You can bind the TreeList to a data collection that implements the INotifyCollectionChanged or IBindingList interface. These collections notify the TreeList about changes and cause automatic updates. For more information, refer to the following help topic: Observable Data Collections.
- Data Instance Change
- If you change an instance of a field/property bound to the Data parameter, the TreeList reloads its data in response to this change. You can use this technique if you post updates to the underlying service (such as DbContext EF Core).
Call the Reload
method after the TreeList’s bound data source is changed. The method gets updated data from the source and applies changes to the TreeList. The following sample binds the TreeList to a List<T> and removes the last item from the list on a button click:
@inject EmployeeTaskService EmployeeTaskService
<div style="margin-bottom: 10px">
<DxButton Text="Remove Last" Click="RemoveLastItem" />
</div>
<DxTreeList @ref="MyTreeList" Data="TreeListData" KeyFieldName="Id" ParentKeyFieldName="ParentId">
<Columns>
<DxTreeListDataColumn FieldName="Name" Caption="Task" />
<DxTreeListDataColumn FieldName="EmployeeName" />
<DxTreeListDataColumn FieldName="StartDate" />
<DxTreeListDataColumn FieldName="DueDate" />
</Columns>
</DxTreeList>
@code {
ITreeList MyTreeList { get; set; }
List<EmployeeTask> TreeListData { get; set; }
protected override void OnInitialized() {
TreeListData = EmployeeTaskService.GenerateData();
}
void RemoveLastItem() {
TreeListData.Remove(TreeListData.Last());
MyTreeList.Reload();
}
}
See Also