Smetko.Paging.Mvc 1.0.1

Razor pager for MVC6 paged lists from Smetko.Paging (first,prev,1,2,3,4..next,last). Easy template override. Check nuget page to see examples.

Install-Package Smetko.Paging.Mvc -Version 1.0.1
dotnet add package Smetko.Paging.Mvc --version 1.0.1
<PackageReference Include="Smetko.Paging.Mvc" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Smetko.Paging.Mvc --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Smetko.Paging

C# library for paginating results in (or out of) ASP.NET CORE MVC 6

Without extension methods.

Usage

var query = context.Product.Where(criteria);

// no mapping
var pagedList = PagedList<Product>.FromQueryable(query); 
var pagedList = PagedList<Product>.FromQueryable(query, pageNumber: 1);
var pagedList = PagedList<Product>.FromQueryable(query, pageNumber: 1, pageSize: 50);

// with mapping
Func<Product, ProductDto> mapper = x => new ProductDto() {Name = x.Name, Price = x.Price};
var pagedList = PagedList<ProductDto>.FromQueryable(query, mapper);
var pagedList = PagedList<ProductDto>.FromQueryable(query, mapper, pageNumber: 1);
var pagedList = PagedList<ProductDto>.FromQueryable(query, mapper, pageNumber: 1, pageSize: 50);

Smetko.Paging.Mvc

Razor tools for rendering paginated results. Requires Smetko.Paging

Usage

Tell MVC how to find paging templates in your Startup.cs

services.Configure<RazorViewEngineOptions>(options =>
{
    options.FileProviders.Add(
        new EmbeddedFileProvider(typeof(Smetko.Paging.UrlHelperExtensions).Assembly));
});

Show pager first, prev,1,2,3,4...,next,last)

@model Smetko.Paging.PagedList<Product>
@{ Html.RenderPartial("_PagerPartial", Model.Pager); }

Extra

To use your own pager template create Views/Shared/_PagerPartial.cshtml:

@using Smetko.Paging
@model Smetko.Paging.Pager

<!-- pager -->
@if (Model.EndPage > 1)
{
    <ul class="pagination">
        @if (Model.CurrentPage > 1)
        {
            <li>
                <a href="@Url.Current(new { pageNumber = 1 })">First</a>
            </li>
            <li>
                <a href="@Url.Current(new { pageNumber = Model.CurrentPage - 1 })">Previous</a>
            </li>
        }

        @for (int page = Model.StartPage; page <= Model.EndPage; page++)
        {
            <li class="@(page == Model.CurrentPage ? "active" : "")">
                <a href="@Url.Current(new { pageNumber = page })">@(page)</a>
            </li>    
        }

        @if (Model.CurrentPage < Model.TotalPages)
        {
            <li>
                <a href="@Url.Current(new { pageNumber = Model.CurrentPage + 1 })">Next</a>
            </li>
            <li>
                <a href="@Url.Current(new { pageNumber = Model.TotalPages })">Last</a>
            </li>
        }
    </ul>
}
<!-- /pager -->

Smetko.Paging

C# library for paginating results in (or out of) ASP.NET CORE MVC 6

Without extension methods.

Usage

var query = context.Product.Where(criteria);

// no mapping
var pagedList = PagedList<Product>.FromQueryable(query); 
var pagedList = PagedList<Product>.FromQueryable(query, pageNumber: 1);
var pagedList = PagedList<Product>.FromQueryable(query, pageNumber: 1, pageSize: 50);

// with mapping
Func<Product, ProductDto> mapper = x => new ProductDto() {Name = x.Name, Price = x.Price};
var pagedList = PagedList<ProductDto>.FromQueryable(query, mapper);
var pagedList = PagedList<ProductDto>.FromQueryable(query, mapper, pageNumber: 1);
var pagedList = PagedList<ProductDto>.FromQueryable(query, mapper, pageNumber: 1, pageSize: 50);

Smetko.Paging.Mvc

Razor tools for rendering paginated results. Requires Smetko.Paging

Usage

Tell MVC how to find paging templates in your Startup.cs

services.Configure<RazorViewEngineOptions>(options =>
{
    options.FileProviders.Add(
        new EmbeddedFileProvider(typeof(Smetko.Paging.UrlHelperExtensions).Assembly));
});

Show pager first, prev,1,2,3,4...,next,last)

@model Smetko.Paging.PagedList<Product>
@{ Html.RenderPartial("_PagerPartial", Model.Pager); }

Extra

To use your own pager template create Views/Shared/_PagerPartial.cshtml:

@using Smetko.Paging
@model Smetko.Paging.Pager

<!-- pager -->
@if (Model.EndPage > 1)
{
    <ul class="pagination">
        @if (Model.CurrentPage > 1)
        {
            <li>
                <a href="@Url.Current(new { pageNumber = 1 })">First</a>
            </li>
            <li>
                <a href="@Url.Current(new { pageNumber = Model.CurrentPage - 1 })">Previous</a>
            </li>
        }

        @for (int page = Model.StartPage; page <= Model.EndPage; page++)
        {
            <li class="@(page == Model.CurrentPage ? "active" : "")">
                <a href="@Url.Current(new { pageNumber = page })">@(page)</a>
            </li>    
        }

        @if (Model.CurrentPage < Model.TotalPages)
        {
            <li>
                <a href="@Url.Current(new { pageNumber = Model.CurrentPage + 1 })">Next</a>
            </li>
            <li>
                <a href="@Url.Current(new { pageNumber = Model.TotalPages })">Last</a>
            </li>
        }
    </ul>
}
<!-- /pager -->

Release Notes

Make view embedded resource

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.1 1,053 11/30/2017
1.0.0 311 11/29/2017