Last active
February 11, 2019 16:29
-
-
Save mikebrind/bcb8c7d114341896a6907de7714086bd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@page "{currentpage=1}/{sortby=Id}" | |
@model PaginationModel | |
<h2>Pagination Example</h2> | |
<table class="table table-striped"> | |
<thead> | |
<tr> | |
<th><a asp-page="pagination" class="sort-link" asp-route-sortby="Id">Id</a></th> | |
<th><a asp-page="pagination" class="sort-link" asp-route-sortby="FullName">Full Name</a></th> | |
<th><a asp-page="pagination" class="sort-link" asp-route-sortby="Country">Country</a></th> | |
<th><a asp-page="pagination" class="sort-link" asp-route-sortby="Email">Email</a></th> | |
<th><a asp-page="pagination" class="sort-link" asp-route-sortby="CreatedAt">Created</a></th> | |
</tr> | |
</thead> | |
@foreach (var item in Model.Data) | |
{ | |
<tr> | |
<td>@item.Id</td> | |
<td>@item.FullName</td> | |
<td>@item.Country</td> | |
<td>@item.Email</td> | |
<td>@item.CreatedAt</td> | |
</tr> | |
} | |
</table> | |
<div> | |
<ul class="pagination"> | |
<li class="page-item @(!Model.ShowFirst? "disabled":"")" title="First"> | |
<a asp-page="pagination" class="page-link" asp-all-route-data="@(new Dictionary<string, string>{ { "currentpage", "1" },{ "sortby", Model.SortBy }})"> | |
<i class="fas fa-fast-backward"></i> | |
</a> | |
</li> | |
<li class="page-item @(!Model.ShowPrevious? "disabled":"")" title="Previous"> | |
<a asp-page="pagination" asp-all-route-data="@(new Dictionary<string, string>{{ "currentpage", (Model.CurrentPage -1).ToString() },{ "sortby", Model.SortBy }})" class="page-link"> | |
<i class="fas fa-step-backward"></i> | |
</a> | |
</li> | |
<li class="page-item @(!Model.ShowNext? "disabled":"")" title="Next"> | |
<a asp-page="pagination" asp-all-route-data="@(new Dictionary<string, string>{{ "currentpage", (Model.CurrentPage + 1).ToString() },{ "sortby", Model.SortBy }})" class="page-link"> | |
<i class="fas fa-step-forward"></i> | |
</a> | |
</li> | |
<li class="page-item @(!Model.ShowLast? "disabled":"")" title="Last"> | |
<a asp-page="pagination" asp-all-route-data="@(new Dictionary<string, string>{{ "currentpage", Model.TotalPages.ToString() },{ "sortby", Model.SortBy }})" class="page-link"> | |
<i class="fas fa-fast-forward"></i> | |
</a> | |
</li> | |
</ul> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment