Giter VIP home page Giter VIP logo

mvcpaging's Introduction

The MvcPaging library contains an ASP.NET MVC HTML helper that renders a pager based on given parameters. A live demo can be found at http://demo.taiga.nl/mvcpaging.

Important information for ASP.NET Core users

This library doesn't support ASP.NET Core. Visit https://github.com/joeaudette/cloudscribe.Web.Pagination for the logical successor of this library. Thanks Joe for the effort!

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

Action(string action, string controller)
	Sets an alternative action and controller for the pager that is different from the current

AddRouteValue(string name, object value)
	Adds a single route value parameter that is added to page url's

AddRouteValueFor<TProperty>(Expression<Func<TModel, TProperty>> expression)
	Adds a strongly typed route value parameter based on the current model
	(e.g. AddRouteValueFor(m => m.SearchQuery))

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.
	Instead of a template name, it's also possible to specify a complete template path, starting with ~/

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.	

PageRouteValueKey
	Set the page routeValue key for pagination links

DisplayFirstAndLastPage
	Displays first and last navigation pages

DisplayFirstPage
	Displays the first navigation page

DisplayLastPage
	Displays the last navigation page

SetFirstPageText
	Set a custom text for the first page

SetFirstPageTitle
	Set a custom text for title attribute of the first page link

SetLastPageText
	Set a custom text for the last page

SetLastPageTitle
	Set a custom text for title attribute of the last page link
	
SetPreviousPageText
	Set a custom text for the previous page

SetPreviousPageTitle
	Set a custom text for title attribute of the previous page link

SetNextPageText
	Set a custom text for the next page

SetNextPageTitle
	Set a custom text for title attribute of the next page link
	
UseItemCountAsPageCount
	The totalItemCount parameter is (ab)used for the total number of pages
	instead of the total number of items to facilitate backends that return the total number
	of pages instead of the total number of items

HidePreviousAndNextPage
	Don't show the 'previous' and 'next' links and only show the page numbers
	
CustomRouteName
	Indicate that a specific named route must be used when generating page links

HideFirstPageNumber
	Don't show page number 1 and '...' when navigating away

HideLastPageNumber
	Don't show the number of the last page and '...' when the last page is more than
	MaxNumberOfPages

PagedList

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

Contributing

Contributions via pull requests are great. We use 4 spaces for indentation :-).

mvcpaging's People

Contributors

martijnboland avatar nicollasricas avatar leebarbara avatar chunkily avatar edokan avatar rafgithub avatar subeax avatar thierryx96 avatar hmol avatar dsouzaj86 avatar cvrajeesh avatar bryant1410 avatar grabmill avatar nhotalling avatar meligy avatar cce32 avatar thecloudlesssky avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.