Pagination

The EPiBoost Pagination functionality is provided through a combination of Filters, Models and DisplayTemplates.

The FilterPagination filter is used to restrict a content collection by page size and page index and generate a Pagination object which is, in turn, used to generate pagination links. Page Size and Index are controlled using querystrings. The keys to these querystrings can be specified in the constructor of the filter.

The Pagination class is used to customize how pagination links are rendered and offers a variety of options to render pagination in many different formats.

Pagination formatting properties

ShowPageLinks Show the numbered page links (Dafault "True")
PageLinkFormat String format for page link text (Default "{0}")
PageLinkSeperatorText Text used to separate numerical page links
MovingWindowSize Number of page number links to show surrounding current page number
LeftLinkWindowSize Number of page number links to show at the start of the list
RightLinkWindowSize Number of page number links to show at the end of the list
WindowSeperatorText Text to seperate the moving window from the left and right page links (Default "...")
PreviousLinkText Text used for the previous page link (Default "Previous")
ShowPreviousLink Enables the previous page link (Default "True")
AutoHidePreviousLink Hides the previous page link when viewing the first
NextLinkText Text used for the next page link (Default "Next")
ShowNextLink Enables the next page link (Default "True")
AutoHideNextLink Hides the next page link when viewing the last page

Usage

Requires DisplayTemplates:
/Views/Shared/DisplayTemplates/Pagination.cshtml


Controller:

int defaultPageSize = 10;
var paginationFilter = new FilterPagination(defaultPageSize);
model.Pages.Filter(new FilterCanRender())
	.Filter(new FilterSort(FilterSortOrder.Alphabetical))
	.Filter(paginationFilter);

model.PaginationLinks = paginationFilter.PaginationLinks;

View:

<div class="pagination">
   @{
Model.PaginationLinks.PreviousLinkText="Prev";
  Model.PaginationLinks.NextLinkText="Next";
}
@Html.DisplayFor(m=>Model.PaginationLinks) </div>

Last edited Nov 14, 2012 at 11:25 AM by jmenziessmith, version 18

Comments

No comments yet.