PagedList分页 [英] PagedList Pagination
问题描述
我使用MVC PagedList。一切工作正常,但情况是这样的。
I'm using PagedList in MVC . Everything works fine but the scenario goes like this.
加载数据。
所以当搜索条件满足SP返回200条记录,分页是这样1 2 3 4 ..(实际想方案),这是按预期工作和每页20。
So when an search condition satisfy SP returns 200 Records , Pagination goes like Page 1 2 3 4 .. ( Actual wanted Scenario) which is working as expected and PageSize 20.
但是,当需求变化
在第1页点击获取20条,第2页获得20条等(从数据库每次点击)..所以初始加载SP将只返回20条记录,而不是实际的(200记录)只有一个分页的第1页显示
When Page 1 Click get 20 records , Page 2 get 20 Records and so on ( each click from Database ).. So on initial load SP will return only 20 Records rather than actual (200 records ) only one Pagination Page 1 Appears
但我们知道实际的200个记录分页应该是第1页第2页第3失败。所以分页是只有20条记录,而不是实际数量,即200创建。
But we know actual 200 records pagination should be Page 1 Page 2 Page 3 it fails . So Pagination is created for only 20 records rather than actual number ie 200 .
是的解决办法是SP的回报作为输出总200条记录,所以我知道一共有多少条记录,但如何覆盖
Html.PagedListPager显示1 2 3 ?????
Yes the work around is SP returns as output total 200 records so i know how many total records but how to overwrite Html.PagedListPager to show Page 1 2 3 ?????
在此先感谢
推荐答案
是的 StaticPagedList 服务的宗旨。
需要一些改动是:
var usersAsIPagedList = new StaticPagedList<CLASSNAME>(LIST, PAGEINDEX, PAGESIZE, TOTALCOUNT);
下面是TOTALCOUNT 200为您的例子。
here TOTALCOUNT is 200 for your example.
在返回视图确保返回的 usersAsIPagedList 并没有 usersAsIPagedList.ToPagedList
While returning view make sure to return usersAsIPagedList and not as usersAsIPagedList.ToPagedList
return PartialView("_PARTIALVIEW", usersAsIPagedList);
这篇关于PagedList分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!