我試圖實現服務器端分頁,與jquery
datatable
篩選。datatable服務器端分頁始終顯示1頁
但它總是隻在頁腳創建一個頁面。
public JsonResult UserList(int draw, int length, int start)
{
PaginattionModel<PointUserModel> paginationModel = new PaginattionModel<PointUserModel>()
{
draw = draw
};
int sortColumn = -1;
string sortDirection = "asc";
if (Request.Form["order[0][column]"] != null)
{
sortColumn = int.Parse(Request.Form["order[0][column]"]);
}
if (Request.Form["order[0][dir]"] != null)
{
sortDirection = Request.Form["order[0][dir]"];
}
int totalCount = 0;
PointUserFilter pointUserFilter = new PointUserFilter()
{
PageSize = length,
PageNumber = start,
SortDirection = sortDirection,
SortColumnNo = sortColumn
};
var getPointUsers = pointUserBl.GetPointUsers(pointUserFilter, out totalCount);
paginationModel.data = getPointUsers;
paginationModel.recordsFiltered = getPointUsers.Count();
paginationModel.recordsTotal = totalCount;
return Json(paginationModel, JsonRequestBehavior.AllowGet);
}
這些是值:
平局= 1,getPointUsers.Count()= 5,TOTALCOUNT = 6
我顯示5個記錄每頁。所以它應該創建2頁。但事實並非如此。
看看:http://www.codeproject.com/Articles/1118363/GridView-with-Server-Side-Filtering-Sorting-and-Pa –
@EhsanSajjad:那麼根據那篇文章。 'totalCount'將始終是表中行數的總和。並且'filteredCount'在應用過濾器後將是全部的記錄數。這意味着'totalcount'永遠不會改變。 我對不對? –
是的,你是對的 –