paginate userlist

This commit is contained in:
Michael 2017-05-22 14:50:06 -04:00
parent 28007dc7df
commit 2be4047502

View file

@ -1,19 +1,26 @@
@model IEnumerable<Project_Unite.Models.ApplicationUser> @model IEnumerable<Project_Unite.Models.ApplicationUser>
@using Project_Unite.Controllers
@{ @{
ViewBag.Moderator = true; ViewBag.Moderator = true;
ViewBag.Title = "Users"; ViewBag.Title = "Users";
int pages = Model.ToArray().GetPageCount(15);
var ordered = Model.OrderBy(x => x.DisplayName).ToArray();
} }
<h2>Users</h2> <h2>Users</h2>
<p>Below is a list of all users in the database.</p> <p>Below is a list of all users in the database.</p>
<table class="table"> <div class="tab-content" >
@for (int i = 1; i < pages; i++)
{
var page = ordered.GetItemsOnPage(i, 15);
<table class="table" id="u_page_@i">
<tr> <tr>
<th style="width:85%">User</th> <th style="width:85%">User</th>
<th>Actions</th> <th>Actions</th>
</tr> </tr>
@foreach (var user in Model) @foreach (var user in page)
{ {
<tr> <tr>
<td>@Html.UserLink(user.Id)</td> <td>@Html.UserLink(user.Id)</td>
@ -25,4 +32,14 @@
</td> </td>
</tr> </tr>
} }
</table> </table>
}
</div>
<ul class="pagination" data-tabs="tabs" id="u_pages">
@for(int i = 1; i < pages; i++)
{
string a = (i == 1) ? "active" : "";
<li class="@a"><a href="#u_page_@i" data-toggle="tab">@i</a></li>
}
</ul>