Paging
1.0.0
Biblioteca de paginación básica para asp.net core
URL de NuGet https://www.nuget.org/packages/Uzzal.Paging
Install-Package Uzzal.Paging -Version 1.0.3
Después de una instalación exitosa, siga estos tres pasos
Paso 1: en el controlador
public IActionResult Index ( int ? page )
{
var itemsPerPage = 10 ;
var list = GetCollection ( ) ; // returns ICollection<string>
var pagedList = list . ToPagedList < string > ( page ?? 1 , itemsPerPage ) ;
return View ( pagedList ) ;
}
private ICollection < string > GetCollection ( ) { .. . }
public async Task < IActionResult > Index ( int ? page )
{
var itemsPerPage = 10 ;
var list = GetRows ( ) ; // returns IQueryable<TEntity>
var pagedList = await list . ToPagedListAsync < TEntity > ( page ?? 1 , itemsPerPage ) ;
return View ( pagedList ) ;
}
private IQueryable < TEntity > GetRows ( ) { .. . }
Paso 2: agregue estas líneas a su archivo
View/_ViewImports.cshtml
@using Uzzal.Paging
@addTagHelper *, Uzzal.Paging
Paso 3: en Razor ver el archivo
@model PagedList < string >
// OR
@model PagedList < TEntity >
< page - links
paging - context = "@Model.GetContext()"
asp - route - param1 = "value1"
asp - route - param2 = "value2"
controller = "Home"
action = "Index" >
< / page - links >
NOTA: La paginación depende del bootstrap 4 para el estilo.
Además, algunos atributos opcionales admitidos son los siguientes:
Nombre del atributo | Valor predeterminado |
---|---|
controller | Controlador actual |
default-style | mr-1 btn btn-outline-primary btn-sm |
active-style | mr-1 btn btn-primary btn-sm |
spacer-text | ... |
spacer-style | p-0 mr-1 btn btn-default btn-sm |