Paging
1.0.0
Biblioteca de paginação básica para núcleo asp.net
URL do NuGet https://www.nuget.org/packages/Uzzal.Paging
Install-Package Uzzal.Paging -Version 1.0.3
Após a instalação bem-sucedida, siga estas três etapas
Etapa 1: no 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 ( ) { .. . }
Etapa 2: adicione essas linhas ao seu arquivo
View/_ViewImports.cshtml
@using Uzzal.Paging
@addTagHelper *, Uzzal.Paging
Etapa 3: no arquivo de visualização do Razor
@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: A paginação depende do bootstrap 4 para estilo.
Além disso, alguns atributos opcionais suportados são os seguintes:
Nome do Atributo | Valor padrão |
---|---|
controller | Controlador atual |
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 |