Created
June 29, 2011 04:23
-
-
Save troygoode/1053136 to your computer and use it in GitHub Desktop.
PagedList MVC Examples
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
<h2>Out-of-the-box Pager Configurations</h2> | |
<h3>Default Paging Control</h3> | |
@Html.PagedListPager((IPagedList)ViewBag.OnePageOfProducts, page => Url.Action("Index", new { page = page })) | |
<h3>Minimal Paging Control</h3> | |
@Html.PagedListPager((IPagedList)ViewBag.OnePageOfProducts, page => Url.Action("Index", new { page = page }), PagedListRenderOptions.Minimal) | |
<h3>Minimal Paging Control w/ Page Count Text</h3> | |
@Html.PagedListPager((IPagedList)ViewBag.OnePageOfProducts, page => Url.Action("Index", new { page = page }), PagedListRenderOptions.MinimalWithPageCountText) | |
<h3>Minimal Paging Control w/ Item Count Text</h3> | |
@Html.PagedListPager((IPagedList)ViewBag.OnePageOfProducts, page => Url.Action("Index", new { page = page }), PagedListRenderOptions.MinimalWithItemCountText) | |
<h3>Page Numbers Only</h3> | |
@Html.PagedListPager((IPagedList)ViewBag.OnePageOfProducts, page => Url.Action("Index", new { page = page }), PagedListRenderOptions.PageNumbersOnly) | |
<h3>Only Show Five Pages At A Time</h3> | |
@Html.PagedListPager((IPagedList)ViewBag.OnePageOfProducts, page => Url.Action("Index", new { page = page }), PagedListRenderOptions.OnlyShowFivePagesAtATime) | |
<!-- ---------------------------------------- --> | |
<h2>Custom Pager Configurations</h2> | |
<h3>Custom Wording (<em>Spanish Translation Example</em>)</h3> | |
@Html.PagedListPager((IPagedList)ViewBag.OnePageOfProducts, page => Url.Action("Index", new { page = page }), new PagedListRenderOptions { LinkToFirstPageFormat = "<< Primera", LinkToPreviousPageFormat = "< Anterior", LinkToNextPageFormat = "Siguiente >", LinkToLastPageFormat = "Ultima >>" }) | |
<h3>Show Range of Items For Each Page</h3> | |
@Html.PagedListPager((IPagedList)ViewBag.OnePageOfProducts, page => Url.Action("Index", new { page = page }), new PagedListRenderOptions { FunctionToDisplayEachPageNumber = page => ((page - 1) * ViewBag.Names.PageSize + 1).ToString() + "-" + (((page - 1) * ViewBag.Names.PageSize) + ViewBag.Names.PageSize).ToString(), MaximumPageNumbersToDisplay = 5 }) | |
<h3>With Delimiter</h3> | |
@Html.PagedListPager((IPagedList)ViewBag.OnePageOfProducts, page => Url.Action("Index", new { page = page }), new PagedListRenderOptions { DelimiterBetweenPageNumbers = "|" }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment