From b5ab8f73023d6d8f84b23ac8366a268285d44685 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 20 May 2021 19:34:21 +0200 Subject: [PATCH] Fix paginatore sul cambio pagina --- MP.Stats/Components/DataPager.razor | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/MP.Stats/Components/DataPager.razor b/MP.Stats/Components/DataPager.razor index eab20eca..6b407189 100644 --- a/MP.Stats/Components/DataPager.razor +++ b/MP.Stats/Components/DataPager.razor @@ -10,7 +10,7 @@ - @for (int i = 1; i <= LastPage; ++i) + @for (int i = @startPage; i <= endPage; ++i) { var pageNum = i; @@ -57,6 +57,28 @@ reportChangePage(); } + private int numPages { get; set; } = 10; + + // calcola un set 1..numPOages centrato sulla pagina corrente... + private int startPage + { + get + { + int answ = (int)(currPage / numPages) * numPages - 2; + answ = answ > 0 ? answ : 1; + return answ; + } + } + private int endPage + { + get + { + int answ = (int)(currPage / numPages) * numPages + numPages + 2; + answ = answ < LastPage ? answ : LastPage; + return answ; + } + } + private int LastPage { get