|
1 |
| -# P.Pager |
| 1 | +# P.Pager |
2 | 2 |
|
3 | 3 | ## Build Status
|
4 | 4 |
|
@@ -53,8 +53,76 @@ public class HomeController : Controller
|
53 | 53 |
|
54 | 54 | ## PagerOptions
|
55 | 55 | Default options for rendering pagination.
|
| 56 | +#### Properties |
| 57 | +|Option|Type|Summary|Default| |
| 58 | +|-----------|-----------|-------|---| |
| 59 | +|DisplayFirstPage|[PagerDisplayMode](#pagerdisplaymode)|If set to Always, render a hyperlink to the first page in the list. If set to IfNeeded, render the hyperlink only when the first page isn't visible in the paging control.|IfNeeded| |
| 60 | +|DisplayLastPage|[PagerDisplayMode](#pagerdisplaymode)|If set to Always, render a hyperlink to the last page in the list. If set to IfNeeded, render the hyperlink only when the last page isn't visible in the paging control.|IfNeeded| |
| 61 | +|DisplayPreviousPage|[PagerDisplayMode](#pagerdisplaymode)|If set to Always, render a hyperlink to the previous page of the list. If set to IfNeeded, render the hyperlink only when there is a previous page in the list.|IfNeeded| |
| 62 | +|DisplayNextPage|[PagerDisplayMode](#pagerdisplaymode)|If set to Always, render a hyperlink to the next page of the list. If set to IfNeeded, render the hyperlink only when there is a next page in the list.|IfNeeded| |
| 63 | +|PagesToDisplay|int?|How many page numbers to display in pagination, by default it is 5.|5| |
| 64 | +|HasIndividualPages|bool|Display pages numbers. Refer [PagesToDisplay]()|true| |
| 65 | +|TextToIndividualPages|string|A formatted text to show to show inside the hyperlink. Use {0} to refer page number, by default it is set to {0}|{0}| |
| 66 | +|TextForDelimiter|string|This will appear between each page number. If null or white space, no delimeter will display.|null| |
| 67 | +|HasEllipses|bool|Adds an ellipe when all page numbers are not displaying, by default it is true.|true| |
| 68 | +|EllipsesFormat|string|A formatted text shows when all pages are not displaying, by default it is …|…| |
| 69 | +|TextToFirstPage|string|A formatted text to show for firstpage link, by default it is set to <<.|<<| |
| 70 | +|TextToPreviousPage|string|A formatted text to show for previous page link, by default it is set to <.|<| |
| 71 | +|TextToNextPage|string|A formatted text to show for next page link, by default it is set to >.|>| |
| 72 | +|TextToLastPage|string|A formatted text to show for last page link, by default it is set to >>.|>>| |
| 73 | +|ClassToPagerContainer|string|Css class to append to <div> element in the paging content, by default it is set to pager container.|container| |
| 74 | +|ClassToUl|string|Css class to append to <ul> element in the paging content, by default it is set to pagination.|pagination| |
| 75 | +|ClassToLi|string|Css class to append to <li> element in the paging content, by default it is set to page-item.|page-item| |
| 76 | +|PageClass|string|Css class to append to <a>/<span> element in the paging content, by default it is set to page-link.|page-link| |
| 77 | +|ClassToActiveLi|string|Css class to append to <li> element if active in the paging content, by default it is set to active.|active| |
| 78 | +|HasPagerText|bool|Displaying current page number and total number of pages in pager, by default it is set to false.|false| |
| 79 | +|PagerTextFormat|string|Text format will display if HasPagerText is true. Use {0} to refer the current page and {0} to refer total number of pages, by default it is set to Page {0} of {1}.|Page {0} of {1}.| |
| 80 | +|HasEntriesText|bool|Displaying start item, last item and total entries in pager, by default it is set to false.|false| |
| 81 | +|EntriesTextFormat|string|Text format will display if HasEntriesText is true. {0} refers first entry on page, {1} refers last item on page and {2} refers total number of entries, by default it is set to Showing {0} to {1} of {2} entries.|Showing {0} to {1} of {2} entries.| |
| 82 | +|||| |
| 83 | + |
| 84 | +### PagerDisplayMode |
| 85 | +A tri-state enum that controls the visibility of portions of the PagerList paging control. |
| 86 | +```csharp |
| 87 | +public enum PagerDisplayMode |
| 88 | +``` |
| 89 | +|Fields|Description| |
| 90 | +|---|----| |
| 91 | +|Always|Always render.| |
| 92 | +|Never|Never render.| |
| 93 | +|IfNeeded|Only render when there is data that makes sense to show (context sensitive).| |
| 94 | +||| |
| 95 | + |
| 96 | +### How to use PagerOptions? |
| 97 | +1. Shows custom page numbers, let say 10 pages. |
| 98 | +```csharp |
| 99 | +@Html.Pager((IPager)Model, page => Url.Action("Index", new { page }), new PagerOptions { PagesToDisplay = 10 }) |
| 100 | +``` |
| 101 | + |
56 | 102 |
|
| 103 | +2. With Custom Page Text. |
| 104 | +```csharp |
| 105 | +@Html.Pager((IPager)Model, page => Url.Action("Index", new { page }), new PagerOptions { TextToIndividualPages = "Page-{0}" }) |
| 106 | +``` |
| 107 | + |
57 | 108 |
|
| 109 | +3. Custom Wording. (<i>Can use for translation also.</i>) |
| 110 | +```csharp |
| 111 | +@Html.Pager((IPager)Model, page => Url.Action("Index", new { page }), new PagerOptions { TextToPreviousPage = "Previous Page", TextToNextPage = "Next Page", TextToFirstPage = "First Page", TextToLastPage = "Last Page" }) |
| 112 | +``` |
| 113 | + |
| 114 | + |
| 115 | +4. Custom options. |
| 116 | +```csharp |
| 117 | +@Html.Pager((IPager)Model, page => Url.Action("Index", new { page }), new PagerOptions { TextToPreviousPage = "last-page", TextToNextPage = "next-page", TextToFirstPage = "first-page", TextToLastPage = "last-page", ClassToUl = "list-inline", ClassToLi = "list-inline-item", PageClass = "nopageclass", ClassToActiveLi = "niloclass", TextForDelimiter = " | " }) |
| 118 | +``` |
| 119 | + |
| 120 | + |
| 121 | +5. Custom Icon Options (Fontawsome) |
| 122 | +```csharp |
| 123 | +@Html.Pager((IPager)Model, page => Url.Action("Index", new { page }), new PagerOptions { TextToPreviousPage = "<i class='fas fa-step-backward'></i>", TextToNextPage = "<i class='fas fa-step-forward'></i>", TextToFirstPage = "<i class='fas fa-fast-backward'></i>", TextToLastPage = "<i class='fas fa-fast-forward'></i>" }) |
| 124 | +``` |
| 125 | + |
58 | 126 | ## PrePagerOptions
|
59 | 127 | 1. Minimal Pager
|
60 | 128 | ```csharp
|
@@ -82,10 +150,13 @@ Default options for rendering pagination.
|
82 | 150 | //Shows Previous and Next page always with default, 5 pages.
|
83 | 151 | @Html.Pager((IPager)Model, page => Url.Action("Index", new { page }), PrePagerOptions.ClassicPager)
|
84 | 152 | ```
|
85 |
| -6. Classic Pager <small>(Classic Pager with First and Last links, but sometimes they are disabled)</small> |
| 153 | + |
| 154 | + |
| 155 | +6. Classic Pager with First and Last<small>(Classic Pager with First and Last links, but sometimes they are disabled)</small> |
86 | 156 | ```csharp
|
87 | 157 | //Shows Last, First, Previous and Next page always with default, 5 pages.
|
88 | 158 | @Html.Pager((IPager)Model, page => Url.Action("Index", new { page }), PrePagerOptions.ClassicPagerWithFirstAndLastPages)
|
89 | 159 | ```
|
| 160 | + |
90 | 161 | ## License
|
91 | 162 | Licensed under the [MIT License](https://github.com/PuffinWeb/P.Pager/blob/master/LICENSE).
|
0 commit comments