From 5cf4efa344539b172218d63871b08954fb4f3f17 Mon Sep 17 00:00:00 2001 From: Sisindry Medagam Date: Sun, 24 Nov 2024 09:49:23 +0530 Subject: [PATCH] readme updated --- README.md | 120 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 81 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index f56e91a..809cb76 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,41 @@ #

P.Pager

## What is this? + P.Pager is Lightweight package for easily paging through any IEnumerable/IQueryable, chop it up into "pages", and grab a specific "page" by an index. It supports Web projects, Winforms, WPF, Window Phone, Silverlight and other .NET projects. It is default configured to **> Bootstrap 3.3.1**. ## How do I use it? + ### Installation + #### .Net Framework ( > 4.5.2) -Install [P.Pager.Mvc](https://www.nuget.org/packages/P.Pager.Mvc/) via [NuGet](http://nuget.org). This will install [P.Pager](https://www.nuget.org/packages/P.Pager/) automatically. + +Install [P.Pager.Mvc](https://www.nuget.org/packages/P.Pager.Mvc/3.0.0) via [NuGet](http://nuget.org). This will install [P.Pager](https://www.nuget.org/packages/P.Pager/3.0.0) automatically. + ``` Install-Package P.Pager.Mvc -Version 3.0.0 ``` -#### .Net Core (.NET Standard 2.0) -Install [P.Pager.Mvc.Core](https://www.nuget.org/packages/P.Pager.Mvc.Core/) via [NuGet](http://nuget.org). This will install [P.Pager](https://www.nuget.org/packages/P.Pager/) automatically. + +#### .Net Core 3 to 5 + +Install [P.Pager.Mvc.Core](https://www.nuget.org/packages/P.Pager.Mvc.Core/3.0.0) via [NuGet](http://nuget.org). This will install [P.Pager](https://www.nuget.org/packages/P.Pager/3.0.0) automatically. + ``` -Install-Package P.Pager.Mvc.Core -Version 1.4.0 +Install-Package P.Pager.Mvc.Core -Version 3.0.0 ``` -#### .Net Core 3 and above (.NET Standard 2.1) -Install [P.Pager.Mvc.Core](https://www.nuget.org/packages/P.Pager.Mvc.Core/) via [NuGet](http://nuget.org). This will install [P.Pager](https://www.nuget.org/packages/P.Pager/) automatically. +#### .Net Core 6 and .Net Core 7 + +Install [P.Pager.Mvc.Core](https://www.nuget.org/packages/P.Pager.Mvc.Core/7.0.0) via [NuGet](http://nuget.org). This will install [P.Pager](https://www.nuget.org/packages/P.Pager/7.0.0) automatically. + ``` -Install-Package P.Pager.Mvc.Core -Version 3.0.0 +Install-Package P.Pager.Mvc.Core -Version 7.0.0 ``` ### After that + 1. In your controller code, call **ToPagerList** off of your IEnumerable/IQueryable passing in the page size. + ```csharp public class HomeController : Controller @@ -40,7 +52,7 @@ public class HomeController : Controller // will only contain 10 members max because of the pageSize. return View(pager); } -} +} ``` 2. Pass the result of **ToPagerList** to your view where you can enumerate over it - its still an IEnumerable, but only contains a child of the original data. @@ -51,114 +63,144 @@ public class HomeController : Controller //Default Pager options @Html.Pager((IPager)Model, page => Url.Action("Index", new { page })) ``` + ![alt text](https://raw.githubusercontent.com/PuffinWeb/P.Pager/master/img/1.default.PNG) ## PagerOptions + Default options for rendering pagination. + #### Properties -|Option|Type|Summary|Default| -|-----------|-----------|-------|---| -|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| -|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| -|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| -|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| -|PagesToDisplay|int?|How many page numbers to display in pagination, by default it is 5.|5| -|HasIndividualPages|bool|Display pages numbers.|true| -|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}| -|TextForDelimiter|string|This will appear between each page number. If null or white space, no delimeter will display.|null| -|HasEllipses|bool|Adds an ellipe when all page numbers are not displaying, by default it is true.|true| -|EllipsesFormat|string|A formatted text shows when all pages are not displaying, by default it is …|…| -|TextToFirstPage|string|A formatted text to show for firstpage link, by default it is set to <<.|<<| -|TextToPreviousPage|string|A formatted text to show for previous page link, by default it is set to <.|<| -|TextToNextPage|string|A formatted text to show for next page link, by default it is set to >.|>| -|TextToLastPage|string|A formatted text to show for last page link, by default it is set to >>.|>>| -|ClassToPagerContainer|string|Css class to append to <div> element in the paging content, by default it is set to pager container.|container| -|ClassToUl|string|Css class to append to <ul> element in the paging content, by default it is set to pagination.|pagination| -|ClassToLi|string|Css class to append to <li> element in the paging content, by default it is set to page-item.|page-item| -|PageClass|string|Css class to append to <a>/<span> element in the paging content, by default it is set to page-link.|page-link| -|ClassToActiveLi|string|Css class to append to <li> element if active in the paging content, by default it is set to active.|active| -|HasPagerText|bool|Displaying current page number and total number of pages in pager, by default it is set to false.|false| -|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}.| -|HasEntriesText|bool|Displaying start item, last item and total entries in pager, by default it is set to false.|false| -|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.| + +| Option | Type | Summary | Default | +| --------------------- | ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------- | +| 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 | +| 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 | +| 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 | +| 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 | +| PagesToDisplay | int? | How many page numbers to display in pagination, by default it is 5. | 5 | +| HasIndividualPages | bool | Display pages numbers. | true | +| 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} | +| TextForDelimiter | string | This will appear between each page number. If null or white space, no delimeter will display. | null | +| HasEllipses | bool | Adds an ellipe when all page numbers are not displaying, by default it is true. | true | +| EllipsesFormat | string | A formatted text shows when all pages are not displaying, by default it is … | … | +| TextToFirstPage | string | A formatted text to show for firstpage link, by default it is set to <<. | << | +| TextToPreviousPage | string | A formatted text to show for previous page link, by default it is set to <. | < | +| TextToNextPage | string | A formatted text to show for next page link, by default it is set to >. | > | +| TextToLastPage | string | A formatted text to show for last page link, by default it is set to >>. | >> | +| ClassToPagerContainer | string | Css class to append to <div> element in the paging content, by default it is set to pager container. | container | +| ClassToUl | string | Css class to append to <ul> element in the paging content, by default it is set to pagination. | pagination | +| ClassToLi | string | Css class to append to <li> element in the paging content, by default it is set to page-item. | page-item | +| PageClass | string | Css class to append to <a>/<span> element in the paging content, by default it is set to page-link. | page-link | +| ClassToActiveLi | string | Css class to append to <li> element if active in the paging content, by default it is set to active. | active | +| HasPagerText | bool | Displaying current page number and total number of pages in pager, by default it is set to false. | false | +| 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}. | +| HasEntriesText | bool | Displaying start item, last item and total entries in pager, by default it is set to false. | false | +| 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. | ### PagerDisplayMode + A tri-state enum that controls the visibility of portions of the PagerList paging control. + ```csharp public enum PagerDisplayMode ``` -|Fields|Description| -|---|----| -|Always|Always render.| -|Never|Never render.| -|IfNeeded|Only render when there is data that makes sense to show (context sensitive).| + +| Fields | Description | +| -------- | ---------------------------------------------------------------------------- | +| Always | Always render. | +| Never | Never render. | +| IfNeeded | Only render when there is data that makes sense to show (context sensitive). | ### How to use PagerOptions? + 1. Shows custom page numbers, let say 10 pages. + ```csharp @Html.Pager((IPager)Model, page => Url.Action("Index", new { page }), new PagerOptions { PagesToDisplay = 10 }) ``` + ![alt text](https://raw.githubusercontent.com/PuffinWeb/P.Pager/master/img/7.custompagenumbers.PNG) 2. With Custom Page Text. + ```csharp @Html.Pager((IPager)Model, page => Url.Action("Index", new { page }), new PagerOptions { TextToIndividualPages = "Page-{0}" }) ``` + ![alt text](https://raw.githubusercontent.com/PuffinWeb/P.Pager/master/img/8.CustomPageText.PNG) 3. Custom Wording. (Can use for translation also.) + ```csharp @Html.Pager((IPager)Model, page => Url.Action("Index", new { page }), new PagerOptions { TextToPreviousPage = "Previous Page", TextToNextPage = "Next Page", TextToFirstPage = "First Page", TextToLastPage = "Last Page" }) ``` + ![alt text](https://raw.githubusercontent.com/PuffinWeb/P.Pager/master/img/9.CustomWording.PNG) 4. Custom options. + ```csharp @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 = " | " }) ``` + ![alt text](https://raw.githubusercontent.com/PuffinWeb/P.Pager/master/img/10.CustomOptions.PNG) 5. Custom Icon Options (Fontawesome) + ```csharp @Html.Pager((IPager)Model, page => Url.Action("Index", new { page }), new PagerOptions { TextToPreviousPage = "", TextToNextPage = "", TextToFirstPage = "", TextToLastPage = "" }) ``` + ![alt text](https://raw.githubusercontent.com/PuffinWeb/P.Pager/master/img/11.Using%20Icons.PNG) ## PrePagerOptions + 1. Minimal Pager + ```csharp //Shows only the Previous and Next links. @Html.Pager((IPager)Model, page => Url.Action("Index", new { page }), PrePagerOptions.Minimal) ``` + ![alt text](https://raw.githubusercontent.com/PuffinWeb/P.Pager/master/img/2.%20minimal.PNG) 2. Minimal Pager with Pager Text (Page Count Text) + ```csharp //Shows Previous and Next links along with current page number and total number of pages in pager. @Html.Pager((IPager)Model, page => Url.Action("Index", new { page }), PrePagerOptions.MinimalWithPagerText) ``` + ![alt text](https://raw.githubusercontent.com/PuffinWeb/P.Pager/master/img/3.minimalpagecount.PNG) 3. Minimal Pager with entries text (Item Count Text) + ```csharp //Shows Previous and Next links along with index of start and last item and total entries in pager. @Html.Pager((IPager)Model, page => Url.Action("Index", new { page }), PrePagerOptions.MinimalWithEntriesText) ``` + ![alt text](https://raw.githubusercontent.com/PuffinWeb/P.Pager/master/img/4.minimalwithentries.PNG) 4. Classic Pager (always shows Previous/Next links, but sometimes they are disabled) + ```csharp //Shows Previous and Next page always with default, 5 pages. @Html.Pager((IPager)Model, page => Url.Action("Index", new { page }), PrePagerOptions.ClassicPager) ``` + ![alt text](https://raw.githubusercontent.com/PuffinWeb/P.Pager/master/img/5.classic.PNG) 6. Classic Pager with First and Last(Classic Pager with First and Last links, but sometimes they are disabled) + ```csharp -//Shows Last, First, Previous and Next page always with default, 5 pages. +//Shows Last, First, Previous and Next page always with default, 5 pages. @Html.Pager((IPager)Model, page => Url.Action("Index", new { page }), PrePagerOptions.ClassicPagerWithFirstAndLastPages) ``` + ![alt text](https://raw.githubusercontent.com/PuffinWeb/P.Pager/master/img/6.classiclastfirst.PNG) ## License + Licensed under the [MIT License](https://github.com/PuffinWeb/P.Pager/blob/master/LICENSE).