Skip to content

Commit

Permalink
Update example. Fix #227
Browse files Browse the repository at this point in the history
  • Loading branch information
ernado-x committed Feb 14, 2023
1 parent 725b0d8 commit 4cd0194
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,20 @@
}
</ul>

@Html.PagedListPager((IPagedList<string>)ViewBag.Names, page => Url.Action("GetOnePageOfNames", new { page }), PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(new PagedListRenderOptions { MaximumPageNumbersToDisplay = 5, DisplayPageCountAndCurrentLocation = true, UlElementClasses = new[] { "pagination" }, ContainerDivClasses = new[] { "pagination-container" } }, new AjaxOptions() { HttpMethod = "GET", UpdateTargetId = "nameListContainer" }))
@Html.PagedListPager(
(IPagedList<string>)ViewBag.Names,
page => Url.Action("GetOnePageOfNames", new { page }),
PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(
new PagedListRenderOptions
{
MaximumPageNumbersToDisplay = 5,
DisplayPageCountAndCurrentLocation = true,
UlElementClasses = new[] { "pagination" },
ContainerDivClasses = new[] { "pagination-container" }
},
new AjaxOptions()
{
HttpMethod = "GET",
UpdateTargetId = "nameListContainer"
})
)
5 changes: 4 additions & 1 deletion src/X.PagedList.Mvc.Core/Common/HtmlHelper.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Text;

Expand Down Expand Up @@ -270,8 +271,10 @@ private ITagBuilder NextEllipsis(IPagedList list, Func<int, string> generatePage

#endregion Private methods

public string PagedListPager(IPagedList list, Func<int, string> generatePageUrl, PagedListRenderOptions options)
public string PagedListPager(IPagedList pagedList, Func<int, string> generatePageUrl, PagedListRenderOptions options)
{
var list = pagedList ?? new StaticPagedList<int>(ImmutableList<int>.Empty, 1, 10, 0);

if (options.Display == PagedListDisplayMode.Never || (options.Display == PagedListDisplayMode.IfNeeded && list.PageCount <= 1))
{
return null;
Expand Down

0 comments on commit 4cd0194

Please sign in to comment.