Comments (8)
@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.
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.
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.
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.
if you use pagedlist together with pagertaghelper you must set them both to the same pagesize
from cloudscribe.web.pagination.
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.
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.
Thank you, I understand.
from cloudscribe.web.pagination.
Related Issues (20)
- Changing css of cs-pager HOT 1
- totalitems with long type HOT 4
- Reference to cloudscribe.Pagination.Models HOT 5
- ToPagedList performance on IQueryable implementation HOT 1
- EINVRES Request to https://bower.herokuapp.com/packages/jquery failed with 502 (fix included) HOT 1
- CompatibilityVersion.Version_2_2 causing NRE HOT 1
- Remove Next and Previous Links HOT 2
- hashtag HOT 4
- reconsider support preserve querystring for creating link HOT 3
- `PagedResult<T> where T : class` why class is needed? HOT 3
- Calling Javascript functions HOT 6
- Add .NET Core 3.0 support HOT 9
- Add netstandard 2.1 Support HOT 1
- Can't use page for cs-pagenumber-param HOT 3
- Problem with total Items
- Please upgrade to .net 6 HOT 4
- How to target another page in Pager Links
- Plans to support .NET 7? HOT 1
- Bootstrap 5 support? HOT 4
- Test and fix demo Pagination web application HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cloudscribe.web.pagination.