Skip to content

Commit

Permalink
Merge pull request dncuug#125 from chadbengen/master
Browse files Browse the repository at this point in the history
  • Loading branch information
ernado-x authored Oct 22, 2018
2 parents 8ba9625 + 1a333c9 commit dbcac0e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

<h3>List of @ViewBag.Names.TotalItemCount Names (Page Size: @ViewBag.Names.PageSize, Current Page: @ViewBag.Names.PageNumber)</h3>
<ol start="@ViewBag.Names.FirstItemOnPage">
@foreach(var i in ViewBag.Names){
<li>@i</li>
}
@foreach(var i in ViewBag.Names){
<li>@i</li>
}
</ol>

<h2>Out-of-the-box Pager Configurations</h2>
Expand Down Expand Up @@ -55,5 +55,28 @@
<h3>Show Range of Items For Each Page</h3>
@Html.PagedListPager((IPagedList)ViewBag.Names, page => Url.Action("Index", new { page }), new PagedListRenderOptions { FunctionToDisplayEachPageNumber = page => ((page - 1) * ViewBag.Names.PageSize + 1).ToString() + "-" + (((page - 1) * ViewBag.Names.PageSize) + ViewBag.Names.PageSize).ToString(), MaximumPageNumbersToDisplay = 5 })

<h3>Custom Options</h3>
@Html.PagedListPager((IPagedList)ViewBag.Names, page => Url.Action("Index", new { page }),
new PagedListRenderOptions
{
DisplayLinkToFirstPage = PagedListDisplayMode.Always,
DisplayLinkToLastPage = PagedListDisplayMode.Always,
DisplayLinkToNextPage = PagedListDisplayMode.Always,
DisplayLinkToPreviousPage = PagedListDisplayMode.Always,
LiElementClasses = new string[] {"page-item"},
PageClasses = new string[] {"page-link"},
ClassToApplyToFirstListItemInPager = "material-icons",
ClassToApplyToLastListItemInPager = "material-icons",
PreviousElementClass = "material-icons",
NextElementClass = "material-icons",
EllipsesElementClass = "material-icons",
LinkToFirstPageFormat = "first_page",
LinkToPreviousPageFormat = "chevron_left",
LinkToLastPageFormat = "last_page",
LinkToNextPageFormat = "chevron_right",
EllipsesFormat = "more_horiz"
})

<h3>Empty PagedList</h3>
@Html.PagedListPager(new string[0].ToPagedList(1, 10), page => Url.Action("Index", new { page }))
@Html.PagedListPager(new string[0].ToPagedList(1, 10), page => Url.Action("Index", new { page }))

12 changes: 8 additions & 4 deletions src/X.PagedList.Mvc/HtmlHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -358,11 +358,13 @@ private static TagBuilder PreviousEllipsis(IPagedList list, Func<int, string> ge
};
previous.Attributes["rel"] = "prev";

previous.AddCssClass("PagedList-skipToPrevious");

if (!list.HasPreviousPage)
return WrapInListItem(previous, options, "PagedList-skipToPrevious", "disabled");
return WrapInListItem(previous, options, options.EllipsesElementClass, "disabled");

previous.Attributes["href"] = generatePageUrl(targetPageNumber);
return WrapInListItem(previous, options, "PagedList-skipToPrevious");
return WrapInListItem(previous, options, options.EllipsesElementClass);
}

private static TagBuilder NextEllipsis(IPagedList list, Func<int, string> generatePageUrl, PagedListRenderOptionsBase options, int lastPageToDisplay)
Expand All @@ -376,11 +378,13 @@ private static TagBuilder NextEllipsis(IPagedList list, Func<int, string> genera

next.Attributes["rel"] = "next";

next.AddCssClass("PagedList-skipToNext");

if (!list.HasNextPage)
return WrapInListItem(next, options, "PagedList-skipToNext", "disabled");
return WrapInListItem(next, options, options.EllipsesElementClass, "disabled");

next.Attributes["href"] = generatePageUrl(targetPageNumber);
return WrapInListItem(next, options, "PagedList-skipToNext");
return WrapInListItem(next, options, options.EllipsesElementClass);
}

///<summary>
Expand Down

0 comments on commit dbcac0e

Please sign in to comment.