Git Product home page Git Product logo

cloudscribe.web.pagination's Introduction

cloudscribe

cloudscribe is a related set of projects and components for building cross platform web applications on ASP.NET Core. Get the big picture at cloudscribe.com

The foundational set of projects in this repository, known as cloudscibe Core, provides support for single tenant or multi tenant management of sites, users, and roles. The other main cloudscribe project is cloudscribe SimpleContent. There are a lot of smaller useful libraries as well, you can find the full list of projects here.

If you have questions please visit our community forums https://www.cloudscribe.com/forum.

Build Status

Windows Linux
Build status Build Status

Twitter URL Twitter Follow

Why Start From Scratch?

Every web application or website project tends to need a certain amount of basic functionality, why build this over and over?

If you start a new web application project in Visual Studio using the standard project templates, what you get is just a basic implementation for user accounts via ASP.NET Identity. Those templates don't provide you any method for creating administrative users or creating roles or managing users and user role membership. You would typically have to implement that stuff yourself, and if you are like me, you don't want to have to implement that stuff again and again on every project. cloudscribe.Core aims to provide that for you with careful, well thought out implementations that adhere to OWASP web security guidelines.

To get started building your own features and applications with cloudscribe, please see our Introduction to learn about our project template for Visual Studio or the .NET Core CLI

Documentation

See the full documentation at cloudscribe.com (work in progress)

Introduction - get the big picture and learn how to start new projects using our project template for Visual Studio or the .NET Core CLI

What Is Included?:
  • Login and registration, with support for social authentication configured from the UI. With options for recaptcha on the login and registration pages
  • Support for extra content on the login page
  • Support for extra content and a terms of use section on the registration page. If you populate the terms of use then users will be required to check a box indicating that they accept the terms in order to register and login. Also if you change the terms later you can optionally force all users to re-accept the changed terms.
  • User Management (optionally multi-tenant user management) you can create and manage user accounts, create and manage roles and user role membership, and add custom claims to users all from the UI. You can optionally disable self serve user registration so that only users that you add are allowed.
  • If you change a user's role membership, the role cookie will be updated automatically so the changes are effective right away.
  • If you lock a user account or delete a user, the user will be signed out automatically.
  • A theme system that supports both shared themes and per tenant themes. You can set the theme from a dropdown list in Administration > Site Settings, and the starter kits have a bunch of bootstrap themes included, and you can also make your own themes.
  • Support for "Site is Closed" - you can set a site as closed and users will not be able to navigate any pages in the site, they will only see the message you provide on the closed page. Users can still login but only members of the Administrators or Content Administrators roles will be allowed to navigate the site, all other users will be redirected to the closed message.
  • You can optionally require a confirmed email address for users if you add SMTP settings for email. A confirmation email will be sent to the user and the user will not be able to login until they click the link to confirm their email address.
  • You can optionally require approval of new accounts before a user can login, and you can get notification when new users register so you can decide whether to approve the account. There is a separate page to make it easy to find users who have not yet been approved or who have not yet confirmed their email address.
  • If you setup social authentication, you can optionally make social authentication the only allowed way to sign in.
  • You can configure SMS settings for Twilio, and then users can enable 2 factor authentication using their phone.
  • There is a company information section where you can define company name, address, email etc, and then you could show that information in the footer for example by customizing the layout. SiteContext is already injected into the layout and the company information are just properties on that so you can wrap your own markup around whichever of those properties you want to show.
  • Integration with IdentityServer4 providing management of users, clients and scopes. This brings us support for Jwt as an alternative to cookie authentication so we can more readily support SPA (Single Page Application) style web apps as well as authentication from mobile devices.
  • Optional LDAP Authentication support
  • Localization Support
  • For data access, supports Entity Framework Core with either SQLite, MSSQL, MySql, or PostgreSql. NoDb file system storage is also supported for small sites or proptypes.
  • Data and IO operations are async all the way down
  • This project aims to follow the OWASP Guidelines for best practices in security
Need Content?

Take a look at cloudscribe.SimpleContent, a simple yet flexible content and blogging engine that works with cloudscribe Core.

Planned Features:
  • Implement options for Security Questions and Answers per OWASP guidelines
  • Implement tracking of password hash history to support scenarios where re-using old passwords is not allowed
  • MongoDB Support - we are interested in trying to implement the data repositories with MongoDB and would welcome help with that.
  • Lots of miscellaneous smaller stuff
Screenshots

administration menu screen shot

Keep In Touch

We are collecting email addresses for a potential newsletter in the future, depending on whether this project becomes popular. If you would like to subscribe to this possible future newsletter, please send an email to subscribe [at] cloudscribe.com with the subject line "subscribe"

If you are interested in consulting or other support services related to cloudscribe, please send an email to info [at] cloudscribe.com.

We're also on twitter at @cloudscribeweb

cloudscribe.web.pagination's People

Contributors

crispinf avatar jimkerslake avatar joeaudette avatar john0king avatar martijnboland avatar thiennn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cloudscribe.web.pagination's Issues

Remove Next and Previous Links

Hi Joe,

I have been using your pagination utility for sometime now and find it very useful. However, I am not a fan of the Next and Previous Links << and >> as they come and go depending on whether you are at the start or end of a set of pages.

I have looked at the code and would propose something along the following...

Add the following to PaginationSettings.cs
public bool RemoveNextPrevLinks { get; set; } = false;

Add to PageTagHelper.cs
[HtmlAttributeName("cs-remove-nextprev-links")]
public bool RemoveNextPrevLinks { get; set; } = false;

Add to PaginationLinkBuilder.cs
// Remove the PREV and NEXT Page Links

if (paginationSettings.RemoveNextPrevLinks)
{
    if (paginationLinks[0].Text == previousPageText) {
        paginationLinks.RemoveAt(0);
    }
    var lastLink = paginationLinks.Count - 1;
    if (paginationLinks[lastLink].Text == nextPageText) {
            paginationLinks.RemoveAt(lastLink);
    }
}

I have read your contribution notes and I think it best to leave you to respond!

Many Thanks
Mark Lawson
[email protected]

Problem with total Items

Hello! I have a problem with my total items. I need to use the query count (no my entire table) since I need to show specific data through a join, When I use TotalItems = query.Count(), it displays pages with same data. my join it works fine I have test it. Any idea? Thank you

I use core 2.2

Calling Javascript functions

Instead of calling an action on a controller, I'm looking to call Javascript functions on click of the numbers and passing the page number as a parameter to the function. Is this functionality possible?

The reason being is I want to post an entire form on the click of the pager buttons so my plan was to use a jquery ajax function to post it like this.

function ChangePage(pageNumber)
{
    $.ajax({
        type: 'POST',
        url: "/Items/ChangePage",
        data: $('#SearchForm').serialize(),
        success: function (result)
        {
            $('#target').html(result);
        }
    });
}

Am I going about this the wrong way?

Missing ToPagedListAsync

It would be nice to have async support when doing database calls with something like ToPagedListAsync() just like there is with toListAsync().

Dealing with a small number of items

Hi,

I was trying out my project asp core 1.1 so I'm using 1.1.4 package... I found this bug:

If you put small number of items like this:

private void InitializeProducts()
		{
			for (var i = 0; i < 7; i++) // <=========== JUST 7 items 
			{
				var product = new Product();
				product.Name = "Product " + (i + 1);
				var categoryIndex = i % 4;
				if (categoryIndex > 2)
				{
					categoryIndex = categoryIndex - 3;
				}
				product.Category = allCategories[categoryIndex];
				allProducts.Add(product);
			}
		}

It won't show anything on the page and the list will be empty.

My controller action looks like this:

public IActionResult Index(int? page)
		{
			var currentPageNum = page.HasValue ? page.Value : 1;

			var model = allProducts.ToPagedList(currentPageNum, 10);

			return View(model);
		}

*P.S: different kind of issue appears if you put 15 items.

Hope there is a fix (something like 1.1.5) for people who still use asp core 1.1.

Hi, Some issues with CSS ?

Hi Joe!

Wanted to thank you for your great project.
I wanted to ask you, for some reason the pagination CSS seems to look awkward, and I couldn't find the reason since all the static resources looks in place.
I attach a picture of how the pagination looks after forked it from Git.
image

It looks the same pretty much in the other paginations examples.

Hope you can figure out where's the problem.
Thank you !
Roni.

cs-paging-maxpageritems attribute does not work

Hi Joe,

Great product, very useful. I'm using your latest nuget package 2.1.2.

I am finding that the cs-paging-maxpageritems attribute is not working, no matter what value I set it to it is still showing the maximum number of page items (in my case 11). I have opened up your demo project and tried adding the attribute in there which works.

Please help.

More PagerTagHelper attributes

It would be nice to have these extra features:

  • add a class to page numbers that are not active or not non-active (so basically normal page numbers).
  • In cs-previous-page-text & cs-next-page-text the ability to use HTML, would be really handy for this: http://materializecss.com/pagination.html etc.
  • The ability to add a class to the previous page active/non-active & next page active/non-active

Features with no working examples

Hello,

I've been experimenting with this library for about a week and so far I really love it. It does a lot with minimal set up and is really powerful. I'm getting a lot of great functionality with minimal code on my part.

But, it's been hard setting up the library and using it correctly. It has required a lot of trial and error on my part. Furthermore, there's a lot of features in this package and I'm having a hard time finding examples for some of them in the sample project and documentation. In particular I'm having difficulty with cs-next-page-html and cs-ajax-loading. For cs-next-page-html, I ended up just having razor encode the html into a string and put it into the -text property. Works fine but doesn't seem optimal. I haven't been able to figure out cs-ajax-loading at all.

A sample or two in the sample project for every feature would be very helpful. I'm using version 1.1.4 if that makes a difference. I looked at the 2.0 sample project and could not find any additional help there.

If I missed something, let me know. Thanks for a great library.

hashtag

Hi, if you added the hashtag to url, it would be great.
Thanks

PagerTagHelper baseHref NullReferenceException

On dnx 4.5.1/core 1.0.0-rc1-final
Problem code:
baseHref = linkTemplate.Attributes["href"];
querySeparator = baseHref.Contains("?") ? "&" : "?";//NullReferenceException
baseHref = baseHref + querySeparator + PageNumberParam + "=";

corrected
baseHref = linkTemplate.Attributes["href"] ?? string.Empty;
querySeparator = baseHref.Contains("?") ? "&" : "?";
baseHref = baseHref + querySeparator + PageNumberParam + "=";

Can't use page for cs-pagenumber-param

Hi
Cloud please help me in razor page (.net core 3.1) when I want paging link with cs-psgenumber-param="page". It doesn't work, and instead of generate link just put # in anchor.

Bag in ajax sample

In Ajax sample /Paging/IndexAjax
clicking on current page Icon (should be no action) leads to unpredictable behaviour.

Not compatible with .net core 1.0 ?

I tried to do a nuget install of this package.

I got an error as follows:
error: Package cloudscribe.Web.Pagination 1.0.2 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package cloudscribe.Web.Pagination 1.0.2 supports:
error: - net451 (.NETFramework,Version=v4.5.1)
error: - net452 (.NETFramework,Version=v4.5.2)
error: - net46 (.NETFramework,Version=v4.6)
error: - netstandard1.6 (.NETStandard,Version=v1.6)
error: One or more packages are incompatible with .NETCoreApp,Version=v1.0.

Is there a compatibility issue?

Hit package conflict after update from beta9 to curent

Errors in C:\XX...XXXProjects\SwiftCourier-master\src\SwiftCourier.Web\SwiftCourier.Web.xproj
Version conflict detected for Microsoft.CodeAnalysis.Common.
SwiftCourier.Web (>= 0.0.1-120) -> Microsoft.NETCore.App (>= 1.0.0-rc2) -> Microsoft.CodeAnalysis.CSharp (>= 1.3.0) -> Microsoft.CodeAnalysis.Common (= 1.3.0)
SwiftCourier.Web (>= 0.0.1-120) -> Microsoft.VisualStudio.Web.CodeGeneration.Tools (>= 1.0.0-preview1-final) -> Microsoft.VisualStudio.Web.CodeGeneration (>= 1.0.0-preview1-final) -> Microsoft.VisualStudio.Web.CodeGeneration.EntityFrameworkCore (>= 1.0.0-preview1-final) -> Microsoft.VisualStudio.Web.CodeGeneration.Core (>= 1.0.0-preview1-final) -> Microsoft.VisualStudio.Web.CodeGeneration.Templating (>= 1.0.0-preview1-final) -> Microsoft.VisualStudio.Web.CodeGeneration.Utils (>= 1.0.0-preview1-final) -> Microsoft.CodeAnalysis.CSharp.Workspaces (>= 1.3.0-beta1-20160429-01) -> Microsoft.CodeAnalysis.Workspaces.Common (= 1.3.0-beta1-20160429-01) -> Microsoft.CodeAnalysis.Common (= 1.3.0-beta1-20160429-01).

CompatibilityVersion.Version_2_2 causing NRE

Using cloudscribe.Web.Pagination 2.1.7. Setting MVC CompatibilityVersion to Version_2_2 causes a NRE when encountering the tag helper. Reverting to Version_2_1 resolves the issue.

services
   .AddMvc(options =>
         {
            options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
         })
   .AddRazorPagesOptions(options =>
        {
           options.Conventions.AuthorizeFolder("/");
        })
  .AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix)
  .SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
<cs-pager cs-paging-pagesize="@Model.PageSize"
    cs-paging-pagenumber="@Model.PageNumber"
    cs-paging-totalitems="@Model.TotalItems"
    cs-pagenumber-param="page"
    asp-controller="Colors"
    asp-action="Index"></cs-pager>
System.NullReferenceException: Object reference not set to an instance of an object.
   at cloudscribe.Web.Pagination.PagerTagHelper.Process(TagHelperContext context, TagHelperOutput output)
   at Microsoft.AspNetCore.Razor.TagHelpers.TagHelper.ProcessAsync(TagHelperContext context, TagHelperOutput output)
   at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner.RunAsync(TagHelperExecutionContext executionContext)
   at AspNetCore.Views_Colors_Index.ExecuteAsync() in C:\src\agon\Agon.Admin.Mvc\Views\Colors\Index.cshtml:line 81
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context)
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage page, ViewContext context, Boolean invokeViewStarts)
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context)

Add option to turn on [ render if only 1 page ]

Add option to turn on [ render if only 1 page ].

It's a good idea to not render if only 1 page, but when you test the page , that don't show anything,it hard to find out that page is paged or not

I think it's a good idea to add a global setting in Startup class, when the Environment is Development turn this on .

Add netstandard 2.1 Support

Cloudscribe Web Pagination doesn't support netstandard 2.1. If you reference Cloudscribe Web Pagination 3 in a netstandard 2.1 class library, you get to this error:

Package cloudscribe.Web.Pagination 3.0.0 is not compatible with netstandard2.1 (.NETStandard,Version=v2.1). Package cloudscribe.Web.Pagination 3.0.0 supports: netcoreapp3.0 (.NETCoreApp,Version=v3.0)

Ajax pagination issue

Hi

In AJAX mode there is an issue with link buttons:
take Paging Demo5 example
Then you start you are at page 1. And back button is disable and even red crossed mouse cursor appear then you put mount over it BUT it still clickable with this red crossed mouse cursor leading to unpredictable behaviour (can be seen on Paging Demo5 sample). Same thing then you click on last page. Last page button become unavailable but still clickable.

reconsider support preserve querystring for creating link

I previously create #25 to discuss this but it close very long ago.

In MVC , the View know nothing about the Controller, but the Controller is the one who know about the Url stuff (querystring, route parameters). Back in asp or aspx age, dynamic build the link is very popular, but now with the routing system , it seems harder than the file base , and this library does not preseve the querystring and only preseve current route value (implement by the default UrlHelper and underling routing system).
I think preserve the querystring is more correct behaviour for a pagination compenent.
for example:

/public/movielist?tag=Marvel      
route: [controller=PublicController&action=Movielist]
query:   tag, sortby, classify

/vip/movieslist?sort=price&TodayUpdate=True  
route:[controller=VipController&action=Movielist]
query:  sort, TodayUpdate, PriceLower, PriceUpper

they use the same View with different ViewComponent/PartialView (the filter panel) , then It's hard to tell the PageTagHelper the right route values, but can be easily do by dynamic build the link .

on the other hand, I just want to go to next page, it'll give me wrong data if the url missing a querystring.

https://github.com/John0King/cloudscribe.Web.Pagination/blob/1b32bd1f7680da40e796dd561612485468a5ba4a/src/cloudscribe.Web.Pagination/PagerTagHelper.cs#L424-L481

this is my fork of your library , the AddCurrentQueryString is what I add , but missing handle the ActionDescriptor.RouteValues ( this is the values that the routing system use for handing controller/action selection , that they must not repeat in RouteValueDictionarys (they will not generate querystring) eg. /home/index?area=top&Action=close )

I suggest to add the QueryString and RouteData.RouteValues process , and a new supress-auto-route attribute to the PageTagHeper , the default value should be false since it won't break any link that you current manual specify the action and controller

the dependency does not support .netframework 4.6

can you target netstandard1.3
dun know but i think 4.6 is the sweet spot atm, also i dun know if azure support 4.6.2.
pulled the repo and converted it and the demo works fine after changing to .netstardard1.3.
installed .netframework 4.6.2 and tried to run teh app it gave reflection expecption and its cause was from this libarary so i pulled the the modified project and refrenced it.
thanks a lot

Add .NET Core 3.0 support

.NET Core 3.0 support can be added this way (tested and works fine)

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <Description>an AspNetCore TagHelper for pagination</Description>
    <Copyright>Source Tree Solutions</Copyright>
    <VersionPrefix>2.1.11</VersionPrefix>
    <AssemblyVersion>2.1.11</AssemblyVersion>
    <Authors>Joe Audette</Authors>
    <TargetFrameworks>netcoreapp3.0;netstandard2.0</TargetFrameworks>
    <PackageTags>cloudscribe;mvc;pagination;navigation;bootstrap</PackageTags>
    <PackageReleaseNotes></PackageReleaseNotes>
    <PackageIconUrl>https://raw.githubusercontent.com/joeaudette/cloudscribe.Web.Pagination/master/cloudscribe-icon-32.png</PackageIconUrl>
    <PackageProjectUrl>https://github.com/joeaudette/cloudscribe.Web.Pagination</PackageProjectUrl>
    <PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
    <RepositoryUrl>https://github.com/cloudscribe/cloudscribe.Web.Pagination.git</RepositoryUrl>
    <RepositoryType>git</RepositoryType>
  </PropertyGroup>

  <ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.1.3" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.1.3" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc.TagHelpers" Version="2.1.3" />
    <PackageReference Include="System.Linq.Queryable" Version="4.3.0" />
  </ItemGroup>
  <PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
    <DefineConstants>NETSTANDARD2_0</DefineConstants>
  </PropertyGroup>

  <ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.0' ">
    <FrameworkReference Include="Microsoft.AspNetCore.App" />
  </ItemGroup>
  <PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
    <DefineConstants>NETCOREAPP3_0</DefineConstants>
  </PropertyGroup>

  <ItemGroup>
    <ProjectReference Include="..\cloudscribe.Pagination.Models\cloudscribe.Pagination.Models.csproj" />
  </ItemGroup>
</Project>

Bootstrap 4 compatibility

Hi.

Thank you for your pager component.

Can you please consider implementing additional parameters for cs-pager tag helper, which can allow to implement bootstrap 4 pager. There are lack of attribute parameter for spans and link inside of page "li" item. So we need something like "cs-pager-link-class".

Thanks in advance.

Best regards Dan.

How to target another page in Pager Links

I can use this in my project with default values.
But for the pager links, it gives me option to specify action and controller.
Since I am not using MVC and using Razor Pages, I need a asp-page parameter to correctly set my target url.

I also have issues with the parameters.

cs-selected-letter-param="query"

option is fine for querystring, but I need it as a route parameter to a razor page.

JavaScript errors

latest version

/Paging/IndexAjax demo generates JavaScript error.
"Empty string passed to getElementById()."
in
/lib/jquery-ajax-unobtrusive/jquery.unobtrusive-ajax.js
at line 28.
Seems like it still works fine with it but this error prevent my JavaScript placed later to work

`PagedResult<T> where T : class` why class is needed?

I have a few questions about the model library

  1. why limit by class ? it seem no need here, since data is a List<T> whitch support struct
  2. why use List<T> instead of IEnumerable<T> ? The .IndexOf extension check if the type is a IList<T> and use it's .Count property instead of re-calculate it's index.

Pagination Not Working

So I've installed the library in my application and configured just as directed both in the read me and sample project, I went on bringing in the sample paging controller inside my project with the view to test the library and everything was just responding as expected. Now, I'm pulling data from database, making sure everything is in the same picture like the paging controller and all I can see is my data table no display of any pagination beneath the table and the code is there with every thing well set but still nothing is coming up for pagination. My data is showing with my filter box ontop but pagination isn't responding but it working fine with the sample paging controller I added to the project.

My project is on Dotnet core 1.1

What could be the problem? there's no error per say.

Just found out that the pagination tag helper isn't rendering, the div closing it is empty.

loading panel

Is any way to trigger JavaScript before and after updating grid? I mean to insert panel with animation on top of page while loading data?

Changing css of cs-pager

Hi Joe,

Is it possible to change the look of the pager element, like background color etc? I tried changing the css base don the class "pagination" but it didn't work for me.

Thanks

PagedList

Hi.
If you click on Page one, Pager show items from page 2.
You can fix it as follows:
PageIndex = index - 1; // HERE ADD -1 TO FIX THIS PROBLEM

HERE IS PART OF CODE WITH this FIX

public PagedList(IQueryable<T> source, int index, int pageSize, int? totalCount = null)
    {
        if (index < 0)
            throw new ArgumentOutOfRangeException("index", "Value can not be below 0.");
        if (pageSize < 1)
            throw new ArgumentOutOfRangeException("pageSize", "Value can not be less than 1.");

        if (source == null)
            source = new List<T>().AsQueryable();

        var realTotalCount = source.Count();

        PageSize = pageSize;
        PageIndex = index - 1; // HERE ADD -1 TO FIX THIS PROBLEM
        TotalItemCount = totalCount.HasValue ? totalCount.Value : realTotalCount;
        PageCount = TotalItemCount > 0 ? (int)Math.Ceiling(TotalItemCount / (double)PageSize) : 0;

        HasPreviousPage = (PageIndex > 0);
        HasNextPage = (PageIndex < (PageCount - 1));
        IsFirstPage = (PageIndex <= 0);
        IsLastPage = (PageIndex >= (PageCount - 1));

        ItemStart = PageIndex * PageSize + 1;
        ItemEnd = Math.Min(PageIndex * PageSize + PageSize, TotalItemCount);

        if (TotalItemCount <= 0)
            return;

        var realTotalPages = (int)Math.Ceiling(realTotalCount / (double)PageSize);

        if (realTotalCount < TotalItemCount && realTotalPages <= PageIndex)
            AddRange(source.Skip((realTotalPages - 1) * PageSize).Take(PageSize));
        else
            AddRange(source.Skip(PageIndex * PageSize).Take(PageSize));
    }

support ajax-begin ajax-complete options

Hi there,
same like this issue
add support for the following parameters
data-ajax-begin -> cs-ajax-begin
data-ajax-complete -> cs-ajax-complete
but they take a callback function not and element if this will make any difference with you.
Thanks a lot

Unable to See First and Last Link in Pager

Thanks for the great code! I downloaded it and have it working (mostly) in an new MVC 6 / .NET 5 Web application. The only problem that I have run across is I am unable to get the First and Last links to display in the output page.

Here is my code:

<cs-pager cs-paging-pagesize="@Convert.ToInt32(ViewData["PageSize"])" cs-paging-pagenumber="@Convert.ToInt32(ViewData["CurrentPage"])" cs-paging-totalitems="@Convert.ToInt32(ViewData["CurrPartCatCount"])" cs-paging-maxpageritems="10" cs-pagenumber-param="page" cs-show-first-last="true" cs-first-page-text="First" cs-next-page-text="Next >" cs-previous-page-text="< Previous" cs-last-page-text="Last" asp-controller="PartCategories" asp-action="Index"></cs-pager>

I am probably missing something stupid. Any help would be appreciated.

Thanks!

Reference to cloudscribe.Pagination.Models

Hi,

is there a reason to have a reference from cloudscribe.Web.Pagination to the cloudscribe.Pagination.Models project. As far as I can see in the code and the documentation this reference is not needed.

tnx!

Search

I used cloudscribe.Web.Pagination in my new project instead of telerik grid as I needed less bulky solution and I do not need filters and other tons of options provided by kendo grid. but what I do need is a proper search option. I see demos and there is some options like filter by category. so

Is it possible to filter result by string containing key words like product name, category name, some other things all together (sort of like autocomplete works)? I mean is it possible without forking project but using current functionality or is it might be possible for you to add suck a feature?

Dima

ToPagedList method returns 0 items

It seems the ToPagedList extension method is returning 0 items back from any types of IEnumerable types I try. I've tried an IEnumerable, ICollection, and IQueryable.

The Demo seems to work fine, but not when I implement this in my application.

Add Custom Attributes

Hi Joe,

Excellent job with this TagHelper for Pagination. I found it very useful for paging, especially the Ajax control.

Can this be extended to add some custom attributes? e.g. data-ajax-success and data-ajax-failure
Basically, I was looking to smooth scroll to the top of the page/div when using Ajax but I need a 'data-ajax-success' attribute..

I've took a local copy down to try out..

Added to your PagerTagHelper.cs:

private const string AjaxSuccessAttributeName = "cs-ajax-success";
 private const string AjaxFailureAttributeName = "cs-ajax-failure";

 [HtmlAttributeName(AjaxSuccessAttributeName)]
 public string AjaxSuccess { get; set; } = string.Empty;

 [HtmlAttributeName(AjaxFailureAttributeName)]
 public string AjaxFailure { get; set; } = string.Empty;

then just added a simple if statement to add the attributes :

 if (AjaxTarget.Length > 0)
                {
                    a.MergeAttribute("data-ajax", "true");
                    a.MergeAttribute("data-ajax-mode", AjaxMode);
                    a.MergeAttribute("data-ajax-update", AjaxTarget);
                    if (AjaxSuccess.Length > 0)
                    {
                        a.MergeAttribute("data-ajax-success", AjaxSuccess);
                    }
                    if (AjaxFailure.Length > 0)
                    {
                        a.MergeAttribute("data-ajax-failure", AjaxFailure);
                    }
                }

Its handy to use as below:

 <cs-pager cs-paging-pagesize="@Model.PageSize"
              cs-paging-pagenumber="@Model.PageNumber"
              cs-paging-totalitems="@Model.TotalItemCount"
              cs-next-page-text="Next Page >"
              cs-previous-page-text="< Previous Page"
              cs-paging-maxpageritems="5"
              cs-pagenumber-param="page"
              cs-ajax-target="#gridcontainer"
              cs-ajax-success="scrollToListingLocation('#gridcontainer')"
              asp-controller="Home"
              asp-action="AjaxPage"
              asp-route-pagesize="@Model.PageSize"  ></cs-pager>

with the simple JS function to auto-scroll to the top of the div:

 function scrollToListingLocation(n) {
        $('html, body').animate({
            scrollTop: $(n).offset().top
        }, 1200);
    }

Is this the best way to do this?

Not Support auto Search?

Current I must define asp-action ,asp-controller,asp-route-* for a search. Is this a Bug?
it should support auto parse QueryString to those links

ToPagedList performance on IQueryable implementation

Test 1:
var list = _context.Posts.ToPagedList(1, 10);

Test 2:
var list = _context.Posts.ToPagedList(1, 10, 100);

Both tests produces the same two sql queries: one for select and one for count. In second case It does not need to call internally IQueryable Count() because count value passed as param.

Hide disabled prev/next button

Hi,
is it possible to hide the disabled prev button on first page and the disabled next button on last page?

I could use some CSS to achive this:

.pagination > li.disabled {
    display: none;
}

But maybe there is or should be a server side solution?

async requests

Is any chance an option to use async requests? like asp.net core rc2 standard template

    public async Task<IActionResult> Index()
    {
        return View(await _context.Reason.ToListAsync());
    }

_context.Reason.ToPagedList(0, DefaultPageSize) does not have ToListAsync method

EINVRES Request to https://bower.herokuapp.com/packages/jquery failed with 502 (fix included)

Hi,

I was having the following problem showing when I ran this demo project:
EINVRES Request to https://bower.herokuapp.com/packages/jquery failed with 502

It was causing bootstrap and JQuery load errors in the browser console.

The fix is to change the .bowercc file to the following (adds "registry": "https://registry.bower.io",):
{
"registry": "https://registry.bower.io",
"directory": "wwwroot/lib"
}

Thank you.

Attribute Routing and page param

I can't seem to get the page param to work for my routes which use attribute routing, using MVC6 and .Net Core.

For example:

[Route("media/{widgetId}/{page?}]
public IActionResult MediaByWidget(int widgetId, int? page)

It works, but it uses a querystring instead such as:
/media/1/?page=1

alphabetic pagination taghelper

currently we have an HtmlHelper AlphabeticPagination.cs, it works fine, but it would be nice to modernize it into a TagHelper instead.

It is not a high priority at the moment but thought I should list it here in case someone else wants to work on that.

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.