feat(module: table): reload data with specific page index and size (#2072)

This commit is contained in:
James Yeung 2021-10-31 14:23:03 +08:00 committed by GitHub
parent a05ab64035
commit a4648d37c5
3 changed files with 48 additions and 1 deletions

View File

@ -6,6 +6,8 @@ namespace AntDesign
{
void ReloadData();
void ReloadData(int? pageIndex, int? pageSize = null);
QueryModel GetQueryModel();
void SetSelection(string[] keys);

View File

@ -1,4 +1,5 @@
using System.Text.RegularExpressions;
using System;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;
@ -134,5 +135,39 @@ namespace AntDesign
StateHasChanged();
}
private void ChangePageSize(int pageSize)
{
pageSize = Math.Max(1, pageSize);
if (_pageSize == pageSize)
{
return;
}
_pageSize = pageSize;
if (PageSizeChanged.HasDelegate)
{
PageSizeChanged.InvokeAsync(_pageSize);
}
}
private void ChangePageIndex(int pageIndex)
{
pageIndex = Math.Max(1, pageIndex);
if (_pageIndex == pageIndex)
{
return;
}
_pageIndex = pageIndex;
if (PageIndexChanged.HasDelegate)
{
PageIndexChanged.InvokeAsync(_pageIndex);
}
}
}
}

View File

@ -217,6 +217,16 @@ namespace AntDesign
this.ReloadAndInvokeChange();
}
public void ReloadData(int? pageIndex, int? pageSize = null)
{
ChangePageIndex(pageIndex ?? 1);
ChangePageSize(pageSize ?? PageSize);
FlushCache();
this.ReloadAndInvokeChange();
}
public QueryModel GetQueryModel() => BuildQueryModel();
private QueryModel<TItem> BuildQueryModel()