forked from martijnboland/MvcPaging
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
54 lines (35 loc) · 1.98 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
The MvcPaging library contains an ASP.NET MVC HTML helper that renders a pager based on given parameters.
Usage (Razor / pseudo code):
@Html.Pager(pageSize, pageNumber, totalItemCount)
Options are added via the Options method:
@Html.Pager(pageSize, pageNumber, totalItemCount).Options(o => o
.Action("action")
.AddRouteValue("q", mySearchQuery)
)
Possible options:
Action(string action)
Sets an alternative action for the pager that is different from the current action
AddRouteValue(string name, object value)
Adds a single route value parameter that is added to page url's
RouteValues(object routeValues)
Adds route value parameters that are added to the page url's
RouteValues(RouteValueDictionary routeValues)
Adds route value parameters that are added to the page url's
DisplayTemplate(string displayTemplate)
When set, the internal HTML rendering is bypassed and a DisplayTemplate view with the given
name is rendered instead. Note that the DisplayTemplate must have a model of type PaginationModel
MaxNrOfPages(int maxNrOfPages)
Sets the maximum number of pages to show
AlwaysAddFirstPageNumber
By default we don't add the page number for page 1 because it results in canonical links.
Use this option to override this behaviour.
--------------------------------------------------------------------------------------------------------
The library contains a PagedList class that makes it easy to work with paged data. Use it via an
extension method on IEnumerable<> or IList<>:
myList.ToPagedList(pageIndex, pageSize)
with any unpaged list or
myList.ToPagedList(pageIndex, pageSize, totalItemCount)
when the list already only contains the data for the page
--------------------------------------------------------------------------------------------------------
For the source and a demo project, see https://github.com/martijnboland/MvcPaging
Read more in the following blog post: http://blogs.taiga.nl/martijn/2008/08/27/paging-with-aspnet-mvc/