JJ.Framework.Presentation 1.5.6883.36449

Easily construct a pager view model with properties like CanGoToFirstPage, CanGoToPreviousPage, CanGoToNextPage, CanGoToLastPage. <<  <  1 2 [3] 4 5 ...  >  >>

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

JJ.Framework.Presentation

Easily construct a pager view model with properties like CanGoToFirstPage, CanGoToPreviousPage, CanGoToNextPage, CanGoToLastPage.

Example call:

PagerViewModelFactory.Create(
    selectedPageNumber: 3, 
    pageSize: 10, 
    itemCount: 200, 
    maxVisiblePageNumbers: 5);

This returns:

PagerViewModel
{
    PageCount = 20,
    CanGoToFirstPage = true,
    CanGoToPreviousPage = true,
    MustShowLeftEllipsis = false,

    VisiblePageNumbers = { 1, 2, 3, 4, 5 },

    PageNumber = 3,

    MustShowRightEllipsis = true,
    CanGoToNextPage = true, 
    CanGoToLastPage = true
}

You can render it any way you want, but you might present it as follows:

<<  <  1 2 [3] 4 5 ...  >  >>

Here is an example of how you could render it with a StringBuilder:

var sb = new StringBuilder();

if (pagerViewModel.CanGoToFirstPage) sb.Append("<< ");
if (pagerViewModel.CanGoToPreviousPage) sb.Append("< ");
if (pagerViewModel.MustShowLeftEllipsis) sb.Append("... ");

foreach (int i in pagerViewModel.VisiblePageNumbers)
{
    if (i == pagerViewModel.PageNumber)
    {
        sb.Append($"[{i}] ");
    }
    else
    {
        sb.Append($"{i} ");
    }
}

if (pagerViewModel.MustShowRightEllipsis) sb.Append("... ");
if (pagerViewModel.CanGoToNextPage) sb.Append(" > ");
if (pagerViewModel.CanGoToLastPage) sb.Append(">>");

JJ.Framework.Presentation

Easily construct a pager view model with properties like CanGoToFirstPage, CanGoToPreviousPage, CanGoToNextPage, CanGoToLastPage.

Example call:

PagerViewModelFactory.Create(
    selectedPageNumber: 3, 
    pageSize: 10, 
    itemCount: 200, 
    maxVisiblePageNumbers: 5);

This returns:

PagerViewModel
{
    PageCount = 20,
    CanGoToFirstPage = true,
    CanGoToPreviousPage = true,
    MustShowLeftEllipsis = false,

    VisiblePageNumbers = { 1, 2, 3, 4, 5 },

    PageNumber = 3,

    MustShowRightEllipsis = true,
    CanGoToNextPage = true, 
    CanGoToLastPage = true
}

You can render it any way you want, but you might present it as follows:

<<  <  1 2 [3] 4 5 ...  >  >>

Here is an example of how you could render it with a StringBuilder:

var sb = new StringBuilder();

if (pagerViewModel.CanGoToFirstPage) sb.Append("<< ");
if (pagerViewModel.CanGoToPreviousPage) sb.Append("< ");
if (pagerViewModel.MustShowLeftEllipsis) sb.Append("... ");

foreach (int i in pagerViewModel.VisiblePageNumbers)
{
    if (i == pagerViewModel.PageNumber)
    {
        sb.Append($"[{i}] ");
    }
    else
    {
        sb.Append($"{i} ");
    }
}

if (pagerViewModel.MustShowRightEllipsis) sb.Append("... ");
if (pagerViewModel.CanGoToNextPage) sb.Append(" > ");
if (pagerViewModel.CanGoToLastPage) sb.Append(">>");

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.5.6883.36449 352 11/5/2018