Skip to content

Commit

Permalink
Merge pull request #12 from csu-chhs/display-pagination
Browse files Browse the repository at this point in the history
Only display pagination when there is more than 1 page
  • Loading branch information
dstegelman authored Apr 16, 2024
2 parents 0b8e482 + 03f72c6 commit 39968a9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 27 deletions.
54 changes: 28 additions & 26 deletions CsuChhs.Blazor/Components/Common/PaginationComponent.razor
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
<nav aria-label="Page navigation example">
<ul class="pagination justify-content-center">
<li class="page-item">
<a class="page-link" href="#" aria-label="Previous" @onclick:preventDefault @onclick="() => GoToPageClick(_previousPage)">
<span aria-hidden="true">&laquo;</span>
</a>
</li>
@{
var x = 0;

while (x < PageCount)
{
x++;
int pageIndex = x;
<li class="page-item @(x == ActivePage ? "active" : "")">
<a class="page-link" href="#" @onclick:preventDefault @onclick="() => GoToPageClick(pageIndex)">@x</a>
</li>
}
}
<li class="page-item">
<a class="page-link" href="#" aria-label="Next" @onclick:preventDefault @onclick="() => GoToPageClick(_nextPage)">
<span aria-hidden="true">&raquo;</span>
</a>
</li>
</ul>
</nav>
@if (PageCount > 1)
{
<nav aria-label="Page navigation example">
<ul class="pagination justify-content-center">
<li class="page-item">
<a class="page-link" href="#" aria-label="Previous" @onclick:preventDefault @onclick="() => GoToPageClick(_previousPage)">
<span aria-hidden="true">&laquo;</span>
</a>
</li>
@{
var x = 0;

while (x < PageCount)
{
x++;
int pageIndex = x;
<li class="page-item @(x == ActivePage ? "active" : "")">
<a class="page-link" href="#" @onclick:preventDefault @onclick="() => GoToPageClick(pageIndex)">@x</a>
</li>
}
}
<li class="page-item">
<a class="page-link" href="#" aria-label="Next" @onclick:preventDefault @onclick="() => GoToPageClick(_nextPage)">
<span aria-hidden="true">&raquo;</span>
</a>
</li>
</ul>
</nav>
}

@code {
[Parameter]
Expand Down
2 changes: 1 addition & 1 deletion CsuChhs.Blazor/CsuChhs.Blazor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>CHHS Application Development Team</Authors>
<Version>1.0.3</Version>
<Version>1.0.4</Version>
<PackageProjectUrl>https://github.com/csu-chhs/CsuChhs.Blazor</PackageProjectUrl>
<Company>College of Health and Human Sciences</Company>
<PackageId>CsuChhs.Blazor</PackageId>
Expand Down

0 comments on commit 39968a9

Please sign in to comment.