diff --git a/framework/src/Volo.Abp.MudBlazorUI/AbpMudCrudPageBase.cs b/framework/src/Volo.Abp.MudBlazorUI/AbpMudCrudPageBase.cs index 9bc201bdca..c702a94318 100644 --- a/framework/src/Volo.Abp.MudBlazorUI/AbpMudCrudPageBase.cs +++ b/framework/src/Volo.Abp.MudBlazorUI/AbpMudCrudPageBase.cs @@ -180,6 +180,7 @@ public abstract class AbpMudCrudPageBase< protected virtual int PageSize { get; set; } = LimitedResultRequestDto.DefaultMaxResultCount; + protected IReadOnlyList Entities = Array.Empty(); protected int CurrentPage = 1; protected string CurrentSorting = default!; protected TGetListInput GetListInput = new TGetListInput(); @@ -349,6 +350,7 @@ public abstract class AbpMudCrudPageBase< await UpdateGetListInputAsync(); var result = await AppService.GetListAsync(GetListInput); var items = MapToListViewModel(result.Items); + Entities = items; await InvokeAsync(StateHasChanged); @@ -599,7 +601,13 @@ public abstract class AbpMudCrudPageBase< protected virtual async Task OnDeletedEntityAsync() { - if (_dataGrid != null) + if (Entities.Count == 1 && CurrentPage > 1) + { + // The data grid loads the previous page when it receives the new CurrentPage + CurrentPage -= 1; + await InvokeAsync(StateHasChanged); + } + else if (_dataGrid != null) { await InvokeAsync(() => _dataGrid.ReloadServerDataAsync()); }