Giter VIP home page Giter VIP logo

Comments (8)

joeaudette avatar joeaudette commented on July 23, 2024

@miroslavsiska said:

If you click on Page one, Pager show items from page 2.

I'm not seeing any problem like this in the demo web for this project. Please provide detailed steps to produce the problem. I cannot test this fix until I can first reproduce the problem.

from cloudscribe.web.pagination.

leozhouchao avatar leozhouchao commented on July 23, 2024

Hi.
page=1;
return View(_context.Contacts.ToPagedList(page-1,1));
Showing page 1
return View(_context.Contacts.ToPagedList(page,1));
Showing page 2

from cloudscribe.web.pagination.

leozhouchao avatar leozhouchao commented on July 23, 2024

Steps:
1.
project.json file
"Dependencies": added "cloudscribe.Web.Pagination": "1.0.0-beta6"
2.
Startup.cs file
Join using cloudscribe.Web.Pagination;
public void ConfigureServices (IServiceCollection services) in
Join services.AddTransient <IBuildPaginationLinks, PaginationLinkBuilder> ();
3.
_ViewImports.cshtml File
join @addTagHelper "*, cloudscribe.Web.Pagination"
4.
Contraller file
Join using cloudscribe.Web.Pagination;
public IActionResult Index (int page = 1)
{
return View (_context.Contacts.ToPagedList (page-1,1));
}
5.
View file
@model cloudscribe.Web.Pagination.IPagedList<CompanyManagementSystems.Models.Contacts>
.....
navigation:
</ cs-pager>

from cloudscribe.web.pagination.

joeaudette avatar joeaudette commented on July 23, 2024

this problem does not happen in the demo web app.

I believe it is a bug in your own code.

Specifically, it looks like you are passing pagesize = 1 to pagedlist but you are not setting the page size on the pagertaghelper so it defaults to 10

from cloudscribe.web.pagination.

joeaudette avatar joeaudette commented on July 23, 2024

if you use pagedlist together with pagertaghelper you must set them both to the same pagesize

from cloudscribe.web.pagination.

leozhouchao avatar leozhouchao commented on July 23, 2024

I changed the code,Debugging。
page=1;
var s = _context.Contacts.ToPagedList(page - 1, 5);
return View(s);
Capacity 8 int
Count 5 int
HasNextPage true bool
HasPreviousPage false bool
IsFirstPage true bool
IsLastPage false bool
ItemEnd 5 int
ItemStart 1 int
PageCount 3 int
PageIndex 0 int
PageNumber 1 int
PageSize 5 int
TotalItemCount 12 int

page=1;
var s = _context.Contacts.ToPagedList(page, 5);
Capacity 8 int
Count 5 int
HasNextPage true bool
HasPreviousPage true bool
IsFirstPage false bool
IsLastPage false bool
ItemEnd 10 int
ItemStart 6 int
PageCount 3 int
PageIndex 1 int
PageNumber 2 int
PageSize 5 int
TotalItemCount 12 int

By contrast, I believe that the issue on PageIndex. PageIndex start counting from 0. Maybe I am wrong, I do not know how to set pagertaghelper. sorry, my English is not very good.

from cloudscribe.web.pagination.

joeaudette avatar joeaudette commented on July 23, 2024

yes pagedlist takes an index parameter and the index is zero based so it is not the same thing as pagenumber

so you need to make a variable
var pageindex = pagenumber -1;
and pass that to pagedlist

pagertaghelper just uses pagenumber, it is not zero based, first page is 1 not 0

you can see this in the demo code
https://github.com/joeaudette/cloudscribe.Web.Pagination/blob/master/src/PagingDemo.Web/Controllers/PagingController.cs

    public IActionResult ProductList(
            int? pageNumber, 
            int? pageSize,
            string query = "")
        {
            int currentPageIndex = pageNumber.HasValue ? pageNumber.Value - 1 : 0;
            int itemsPerPage = pageSize.HasValue ? pageSize.Value : DefaultPageSize;

            var model = new ProductListViewModel();

            model.Products = this.allProducts.Where(p => 
            p.Category.StartsWith(query)
            ).ToPagedList(currentPageIndex, itemsPerPage);

            model.Paging.CurrentPage = pageNumber.HasValue ? pageNumber.Value : 1;
            model.Paging.ItemsPerPage = itemsPerPage;
            model.Paging.TotalItems = model.Products.TotalItemCount;
            model.Query = query; //TODO: sanitize

            return View(model);


        }

from cloudscribe.web.pagination.

leozhouchao avatar leozhouchao commented on July 23, 2024

Thank you, I understand.

from cloudscribe.web.pagination.

Related Issues (20)

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.