diff --git a/src/PagedList.Mvc/HtmlHelper.cs b/src/PagedList.Mvc/HtmlHelper.cs
index cfb6835..60db6e3 100644
--- a/src/PagedList.Mvc/HtmlHelper.cs
+++ b/src/PagedList.Mvc/HtmlHelper.cs
@@ -122,15 +122,18 @@ private static TagBuilder ItemSliceAndTotalText(IPagedList list, PagedListRender
return WrapInListItem(text, options, "PagedList-pageCountAndLocation", "disabled");
}
- private static TagBuilder Ellipses(PagedListRenderOptions options)
- {
- var a = new TagBuilder("a")
- {
- InnerHtml = options.EllipsesFormat
- };
+ private static TagBuilder Ellipses(PagedListRenderOptions options, Func generatePageUrl, int targetPageNumber)
+ {
+ var a = new TagBuilder("a")
+ {
+ InnerHtml = options.EllipsesFormat
+ };
- return WrapInListItem(a, options, "PagedList-ellipses", "disabled");
- }
+ if (options.EnableEllipsesNavigation)
+ a.Attributes["href"] = generatePageUrl(targetPageNumber);
+
+ return WrapInListItem(a, options, "PagedList-ellipses", options.EnableEllipsesNavigation ? null : "disabled");
+ }
///
/// Displays a configurable paging control for instances of PagedList.
@@ -202,7 +205,7 @@ public static MvcHtmlString PagedListPager(this System.Web.Mvc.HtmlHelper html,
{
//if there are previous page numbers not displayed, show an ellipsis
if (options.DisplayEllipsesWhenNotShowingAllPageNumbers && firstPageToDisplay > 1)
- listItemLinks.Add(Ellipses(options));
+ listItemLinks.Add(Ellipses(options, generatePageUrl, firstPageToDisplay - 1));
foreach (var i in Enumerable.Range(firstPageToDisplay, pageNumbersToDisplay))
{
@@ -216,7 +219,7 @@ public static MvcHtmlString PagedListPager(this System.Web.Mvc.HtmlHelper html,
//if there are subsequent page numbers not displayed, show an ellipsis
if (options.DisplayEllipsesWhenNotShowingAllPageNumbers && (firstPageToDisplay + pageNumbersToDisplay - 1) < list.PageCount)
- listItemLinks.Add(Ellipses(options));
+ listItemLinks.Add(Ellipses(options, generatePageUrl, (firstPageToDisplay + pageNumbersToDisplay)));
}
//next
diff --git a/src/PagedList.Mvc/PagedListRenderOptions.cs b/src/PagedList.Mvc/PagedListRenderOptions.cs
index 985c53b..30e183a 100644
--- a/src/PagedList.Mvc/PagedListRenderOptions.cs
+++ b/src/PagedList.Mvc/PagedListRenderOptions.cs
@@ -38,6 +38,7 @@ public PagedListRenderOptions()
ContainerDivClasses = new [] { "pagination-container" };
UlElementClasses = new[] { "pagination" };
LiElementClasses = Enumerable.Empty();
+ EnableEllipsesNavigation = false;
}
///
@@ -204,6 +205,11 @@ public PagedListRenderOptions()
/// An extension point which allows you to fully customize the anchor tags used for clickable pages, as well as navigation features such as Next, Last, etc.
///
public Func FunctionToTransformEachPageLink { get; set; }
+
+ ///
+ /// Enables or disables the navigation functionality of the ellipses
+ ///
+ public bool EnableEllipsesNavigation { get; set; }
///
/// Enables ASP.NET MVC's unobtrusive AJAX feature. An XHR request will retrieve HTML from the clicked page and replace the innerHtml of the provided element ID.
diff --git a/src/PagedList.Mvc4.Example/Views/TraditionalPaging/Index.cshtml b/src/PagedList.Mvc4.Example/Views/TraditionalPaging/Index.cshtml
index ebe448e..5da2ef0 100644
--- a/src/PagedList.Mvc4.Example/Views/TraditionalPaging/Index.cshtml
+++ b/src/PagedList.Mvc4.Example/Views/TraditionalPaging/Index.cshtml
@@ -47,6 +47,9 @@
Custom Pager Configurations
+Functional Ellipses
+@Html.PagedListPager((IPagedList)ViewBag.Names, page => Url.Action("Index", new { page }), new PagedListRenderOptions() { EnableEllipsesNavigation = true })
+
Custom Wording (Spanish Translation Example)
@Html.PagedListPager((IPagedList)ViewBag.Names, page => Url.Action("Index", new { page }), new PagedListRenderOptions { LinkToFirstPageFormat = "<< Primera", LinkToPreviousPageFormat = "< Anterior", LinkToNextPageFormat = "Siguiente >", LinkToLastPageFormat = "Ăšltima >>" })