Coder Social home page Coder Social logo

pagedlist.core.mvc's Introduction

PagedList.Core.Mvc

PagedList tag helper for ASP.NET Core

Installation

  1. Install PagedList.Core.Mvc package from Nuget.

  2. Edit _ViewImports.cshtml

@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
+ @addTagHelper *, PagedList.Core.Mvc

Usage

<pager class="pager-container" list="@Model.SearchResult.SearchHits" options="@PagedListRenderOptions.Bootstrap4" asp-action="Index" asp-controller="Search" asp-route-query="@Model.SearchResult.SearchQuery" />

Sample

Sample

pagedlist.core.mvc's People

Contributors

hieudole avatar adams85 avatar jledgett avatar

Stargazers

Nguyễn Quang Thanh avatar Srgjan Ristovski avatar  avatar  avatar weli avatar  avatar Matthew Eskolin avatar Brendon avatar Kiarash Soleimanzadeh avatar  avatar  avatar gogoya avatar Yunus avatar  avatar Jack Chang avatar  avatar Romuald Ferrante avatar Mehmet Emin Eker avatar loogn avatar Alexander R Torrijos avatar Nongzhsh avatar  avatar Joseph Gimness avatar <eat-sleep-code/> avatar jeffw avatar

Watchers

Alexander R Torrijos avatar James Cloos avatar  avatar  avatar

pagedlist.core.mvc's Issues

Breaking Change In 2.0.0

In prior versions there was an option to suppress the Prev and Next buttons and display Page Numbers Only by using this kind of syntax:

<pager class="history-pager" list="@((IPagedList)ViewBag.PageOfData)" options="@PagedListRenderOptions.PageNumbersOnly" asp-controller="Pages" asp-action="History" />

But now, that option seems to have been moved or removed. What is the equivalent?

Specifying PagedListDisplayMode?

I am transitioning some code from PagedList.Mvc to PagedList.Mvc.Core.

Now there is the pager HTML helper, what attribute do you use to set the PagedListDisplayMode?

I know I can specify, options="@PagedListRenderOptions.PageNumbersOnly" to set the render options.

But, Visual Studio's Intellisense is not giving any hints on how specify the PagedListDisplayMode.

Pagination class instead of pager

I believe you want to assign the unordered list a class of 'pagination' instead of 'pager' (or have the option to do so when using options>PagedListRenderOptions.TwitterBootstrapPager

Pager from bootstrap is designed as a next/prev functionality pretty much, whereas when using actual page numbers, you want to use pagination.

http://getbootstrap.com/components/#pagination

Globalization

Hello.

Please, how can I change the labels to my local language? I tried to change in the source code, compiled and imported to my project, but then I get some erros (IPagedList and StaticPagedList). I googled and didn't found anything about it.
I tried to change in the PagedListRenderOptions and in PagedListRenderOptionsBootstrap4 classes.

Thank you!

Sql Server version compatibility

I think, from reading the internet you have a reliance on SQL Server 2012. I am getting

SELECT [o].[SITE_ID], [o].[ENDPOINT_ID], [o].[ALEXA_TYPE], [o].[CREATED], [o].[CREATED_BY], [o].[DELETED], [o].[DESCRIPTION], [o].[ENABLED], [o].[VALID]
FROM [ALEXA_ENDPOINT] AS [o]
WHERE [o].[ALEXA_TYPE] IN (0, 1) AND ([o].[SITE_ID] = @__id_0)
ORDER BY [o].[DESCRIPTION]
OFFSET @__p_1 ROWS FETCH NEXT @__p_2 ROWS ONLY

If I run this code with parameters in place it fails on SQL Server 2008
http://erikej.blogspot.co.uk/2014/12/a-breaking-change-in-entity-framework.html

Please can you look to make it downgrade successfully

Thanks
Mark

Add bootstrap 4 pagination

Souce code changes:

PagedListRenderOptions.cs:
public IEnumerable AhrefElementClasses { get; set; }

    public static PagedListRenderOptions TwitterBootstrapPager4
    {
        get
        {
            return new PagedListRenderOptions
            {
                DisplayLinkToFirstPage = PagedListDisplayMode.Never,
                DisplayLinkToLastPage = PagedListDisplayMode.Never,
                DisplayLinkToPreviousPage = PagedListDisplayMode.Always,
                DisplayLinkToNextPage = PagedListDisplayMode.Always,
                DisplayLinkToIndividualPages = true,
                UlElementClasses = new[] { "pagination" },
                LiElementClasses = new[] { "page-item" },
                AhrefElementClasses = new[] {"page-link"},
                ClassToApplyToFirstListItemInPager = null,
                ClassToApplyToLastListItemInPager = null,
                LinkToPreviousPageFormat = "Previous",
                LinkToNextPageFormat = "Next"
            };
        }
    }

PageTagHeler.cs

    private TagBuilder First()
    {
        const int targetPageNumber = 1;
        var first = new TagBuilder("a");
        foreach (var @class in this.Options.AhrefElementClasses)
        {
            first.AddCssClass(@class);
        }

        first.InnerHtml.AppendHtml(string.Format(this.Options.LinkToFirstPageFormat, targetPageNumber));

        if (this.List.IsFirstPage) {
            return WrapInListItem(first, "PagedList-skipToFirst", "disabled");
        }

        first.Attributes["href"] = GeneratePageUrl(targetPageNumber);
        return WrapInListItem(first, "PagedList-skipToFirst");
    }

    private TagBuilder Previous()
    {
        var targetPageNumber = this.List.PageNumber - 1;
        var previous = new TagBuilder("a");

        foreach (var @class in this.Options.AhrefElementClasses)
        {
            previous.AddCssClass(@class);
        }

        previous.InnerHtml.AppendHtml(string.Format(this.Options.LinkToPreviousPageFormat, targetPageNumber));
        previous.Attributes["rel"] = "prev";

        if (!this.List.HasPreviousPage)
        {
            return WrapInListItem(previous, "PagedList-skipToPrevious", "disabled");
        }

        previous.Attributes["href"] = this.GeneratePageUrl(targetPageNumber);

        return WrapInListItem(previous, "PagedList-skipToPrevious");
    }

    private TagBuilder Page(int i)
    {
        var format = this.Options.FunctionToDisplayEachPageNumber
            ?? (pageNumber => string.Format(this.Options.LinkToIndividualPageFormat, pageNumber));
        var targetPageNumber = i;
        var page = new TagBuilder("a");
        foreach (var @class in this.Options.AhrefElementClasses)
        {
            page.AddCssClass(@class);
        }

        page.InnerHtml.AppendHtml(format(targetPageNumber));

        if (i == this.List.PageNumber)
            return WrapInListItem(page, "active");

        page.Attributes["href"] = this.GeneratePageUrl(targetPageNumber);
        return WrapInListItem(page);
    }

    private TagBuilder Next()
    {
        var targetPageNumber = this.List.PageNumber + 1;
        var next = new TagBuilder("a");
        foreach (var @class in this.Options.AhrefElementClasses)
        {
            next.AddCssClass(@class);
        }

        next.InnerHtml.AppendHtml(string.Format(this.Options.LinkToNextPageFormat, targetPageNumber));
        next.Attributes["rel"] = "next";

        if (!this.List.HasNextPage)
        {
            return WrapInListItem(next, "PagedList-skipToNext", "disabled");
        }

        next.Attributes["href"] = this.GeneratePageUrl(targetPageNumber);
        return WrapInListItem(next, "PagedList-skipToNext");
    }

    private TagBuilder Last()
    {
        var targetPageNumber = this.List.PageCount;
        var last = new TagBuilder("a");
        foreach (var @class in this.Options.AhrefElementClasses)
        {
            last.AddCssClass(@class);
        }

        last.InnerHtml.AppendHtml(string.Format(this.Options.LinkToLastPageFormat, targetPageNumber));

        if (this.List.IsLastPage)
        {
            return WrapInListItem(last, "PagedList-skipToLast", "disabled");
        }

        last.Attributes["href"] = this.GeneratePageUrl(targetPageNumber);
        return WrapInListItem(last, "PagedList-skipToLast");
    }

Please make PagedListRenderOptions partial class to add custom button text and styles.

Can it have support for bootstrap 4?

Would you please add bootstrap 4 pagination support?

So that the <li> tag can comes with "page-item" class and <a> tag can come with "Page-link" class.
some thing like this.

<ul class="pagination pagination-sm">
  <li class="page-item"><a class="page-link" href="#">Previous</a></li>
  <li class="page-item"><a class="page-link" href="#">1</a></li>
  <li class="page-item"><a class="page-link" href="#">2</a></li>
  <li class="page-item"><a class="page-link" href="#">3</a></li>
  <li class="page-item"><a class="page-link" href="#">Next</a></li>
</ul>

怎么没更新啦

很好用,提一个优化点,当不设置asp-controller时,希望能默认补全;
当pagecout=0时,不要显示分页。
如:
<pager class="pager-container pull-right" list="@model" options="@PagedListRenderOptions.ClassicPlusFirstAndLast" asp-action="Index"param-page-number="id" />

PagedList.Core.Mvc 2.1.0 appears to be broken in .NET Core 3.0.

Perhaps I missed something in my migration to .NET Core 3.0, but all other parts of my page are running flawlessly.

I have the following in my code:

@if (ViewBag.PageCount > 1) { <div class="pagination-container"> <pager class="news-pager" list="@((IPagedList)ViewBag.PageOfData)" options="@PagedListRenderOptions.Bootstrap4PageNumbersOnly" asp-controller="Pages" asp-action="News" /> </div> }

The following is output on my page:

<div class="pagination-container"> <pager class="news-pager" list="PagedList.Core.PagedList1[Framework.Models.NewsItem]" options="PagedList.Core.Mvc.PagedListRenderOptions" asp-controller="Pages" asp-action="News">
`

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.