Jtable分页和排序不会到来 [英] Jtable paging and sorting is not coming

查看:79
本文介绍了Jtable分页和排序不会到来的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的一个项目中使用了一个jTable。我正在尝试在jTbale中实现分页和排序。数据来自jTable。我已经将pagesize作为5.但是所有记录(在我的情况下为11个)都显示在第一页的表格而不是5个记录中。



我的理解是我没有在下面的控制器代码中正确使用jtStartIndex,jtPageSize这两个属性。请在不使用存储库的情况下通过提供解决方案帮助我...





预先感谢您的支持。



我的cshtml代码是这样的



I am using a jTable in one of my project.I am trying to implement paging and sorting in jTbale.The data are coming in jTable. I have given pagesize as 5.but all records(11 in count in my case) are showing in the table in the first page instead of 5 records..

My understanding is I am not using jtStartIndex ,jtPageSize these two properties properly in the below controller code.Please help me out by providing the solution without using repository...


Thanks in advance for your support.

my cshtml code is like that

$('#PersonTableContainer').jtable({
               title: 'Table of people',
               paging: true,
               pageSize: 5,
               sorting: true,
               defaultSorting: 'Name ASC',
               actions: {
                   listAction: '/Account/AdminList';,
                   
               updateAction: '/Account/UpdateAdmin',





这样的控制器代码



#region jTable

[HttpPost]

public JsonResult AdminList(int jtStartIndex = 0,int jtPageSize = 0,string jtSorting = null)

{

尝试

{

//从数据库获取数据

int count = new GETEvaluationPortalEntities() .Users.Count();

IList用户> admins = new GETEvaluationPortalEntities()。Users.ToList();



//将结果返回给jTable

返回Json(new {Result = OK,Records = admins,TotalRecordCount = count});

}

catch(Exception ex)

{

返回Json(new {Result =ERROR,Message = ex.Message});

}

}



Controller code like that

#region jTable
[HttpPost]
public JsonResult AdminList(int jtStartIndex = 0,int jtPageSize = 0, string jtSorting = null)
{
try
{
//Get data from database
int count = new GETEvaluationPortalEntities().Users.Count();
IList User> admins = new GETEvaluationPortalEntities().Users.ToList();

//Return result to jTable
return Json(new { Result = "OK", Records = admins, TotalRecordCount = count });
}
catch (Exception ex)
{
return Json(new { Result = "ERROR", Message = ex.Message });
}
}

推荐答案

' #PersonTableContainer')。jtable({
title :' 人员表
分页: true
pageSize: 5
排序: true
defaultSorting:' 名称ASC',
操作:{
listAction:' / Account / AdminList';,

updateAction:' /帐户/ UpdateAdmin'
('#PersonTableContainer').jtable({ title: 'Table of people', paging: true, pageSize: 5, sorting: true, defaultSorting: 'Name ASC', actions: { listAction: '/Account/AdminList';, updateAction: '/Account/UpdateAdmin',





这样的控制器代码



#region jTable

[HttpPost]

public JsonResult AdminList(int jtStartIndex = 0,int jtPageSize = 0,string jtSorting = null)

{

尝试

{

//从数据库获取数据

int count = new GETEvaluationPortalEntities( ).Users.Count();

IList用户> admins = new GETEvaluationPortalEntities()。Users.ToList();



//将结果返回给jTable

返回Json(new {Result = OK,Records = admins,TotalRecordCount = count});

}

catch(Exception ex)

{

返回Json(new {Result =ERROR,Message = ex.Message});

}

}



Controller code like that

#region jTable
[HttpPost]
public JsonResult AdminList(int jtStartIndex = 0,int jtPageSize = 0, string jtSorting = null)
{
try
{
//Get data from database
int count = new GETEvaluationPortalEntities().Users.Count();
IList User> admins = new GETEvaluationPortalEntities().Users.ToList();

//Return result to jTable
return Json(new { Result = "OK", Records = admins, TotalRecordCount = count });
}
catch (Exception ex)
{
return Json(new { Result = "ERROR", Message = ex.Message });
}
}


这篇关于Jtable分页和排序不会到来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆