Browse Source

Go back to the previous page when the last item of a MudBlazor CRUD page is deleted

pull/26328/head
maliming 4 weeks ago
parent
commit
cb431a15aa
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  1. 10
      framework/src/Volo.Abp.MudBlazorUI/AbpMudCrudPageBase.cs

10
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<TListViewModel> Entities = Array.Empty<TListViewModel>();
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());
}

Loading…
Cancel
Save