Код: Выделить всё
@implements IDisposable
@inject IRecordServices RecordServices
@inject DialogService DialogService
@inject IJSRuntime js
@inject Radzen.NotificationService NotificationService
@inject PersistentComponentState ApplicationState
@rendermode InteractiveServer
..............DataGrid populated with records...............
IEnumerable? records;
RadzenDataGrid grid = new RadzenDataGrid();
PersistingComponentStateSubscription rendering = new PersistingComponentStateSubscription();
protected override async Task OnInitializedAsync()
{
rendering = ApplicationState.RegisterOnPersisting(() =>
{
ApplicationState.PersistAsJson(nameof(records), records);
return Task.CompletedTask;
});
if (!ApplicationState.TryTakeFromJson(nameof(records), out IEnumerable? restored))
records = await GetAllRecordsForGrid();
else
records = restored;
}
private async Task GetAllRecordsForGrid()
{
return await RecordServices.GetRecordEntities();
}
public void Dispose()
{
rendering.Dispose();
}
Код: Выделить всё
OnInitializedAsync()
Я действительно хочу, чтобы это постоянное состояние работало, чтобы компонент не отображался дважды.
Что я делаю не так?
Подробнее здесь: https://stackoverflow.com/questions/791 ... rver-error