gpt4 book ai didi

asp.net-mvc - loadonce :true in jqGrid 时分页不工作

转载 作者:行者123 更新时间:2023-12-02 05:00:01 24 4
gpt4 key购买 nike

在 jqGrid 中有属性 loadonce:true 然后我只得到首页记录。如何获取第二页和第三页记录。

代码:

$(function () {

$("#pendingAppgrid").jqGrid({
colNames: ['Name', 'Email'],
colModel: [
{ name: 'Name', index: 'Name', sortable: true, align: 'left', width: '200',
editable: false, edittype: 'text',search:true

},

{ name: 'Email', index: 'Email', sortable: false, align: 'left', width: '200',
editable: false, edittype: 'text',search:true
},
],
pager: jQuery('#pager'),
sortname: 'Name',
rowNum: 15,
rowList: [10, 20, 25],
sortorder: "desc",
height: 345,
ignoreCase: true,
viewrecords: true,
rownumbers: true,
caption: 'Pending Approvals',
width: 660,
url: "@Url.Content("~/Home/PendingApprovals")",
datatype: 'json',
mtype: 'GET',
loadonce: true
})
jQuery("#pendingAppgrid").jqGrid('filterToolbar', { searchOnEnter: true, enableClear: false });

});

服务器代码

public ActionResult PendingApprovals(int page, int rows, string sidx, string sord)
{

//return View(GetPendingApprovals());
int currentPage = Convert.ToInt32(page) - 1;
int totalRecords = 0;
List<ViewModels.Channel.UserChannels> lTemChannel = new List<ViewModels.Channel.UserChannels>();
List<ViewModels.Channel.UserChannels> lstChannel = new List<ViewModels.Channel.UserChannels>();
lTemChannel = GetPendingApprovals();
foreach (ViewModels.Channel.UserChannels cha in lTemChannel)
{
ViewModels.Channel.UserChannels channelWithLogo = new ViewModels.Channel.UserChannels();
channelWithLogo.ID = cha.ID;
channelWithLogo.Name = cha.Name;
channelWithLogo.Email = cha.Email;

lstChannel.Add(channelWithLogo);
}
totalRecords = lstChannel.Count;
var totalPages = (int)Math.Ceiling(totalRecords / (float)rows);
lstChannel = lstChannel.ToList<ViewModels.Channel.UserChannels>();

IPagedList<ViewModels.Channel.UserChannels> ilstChannel;
switch (sord)
{
case "desc":
ilstChannel = lstChannel.OrderByDescending(m => m.Name).ToPagedList(page, rows);
break;
case "asc":
ilstChannel = lstChannel.OrderBy(m => m.Name).ToPagedList(page, rows);
break;
default:
ilstChannel = lstChannel.OrderBy(m => m.Name).ToPagedList(page, rows);
break;
}

var data = ilstChannel;

var jsonData = new
{
total = totalPages,
page,
records = totalRecords,

rows = (from m in data
select new
{

id = m.ChannelID,
cell = new object[]
{
m.Name,
m.Email
}
}).ToArray()
};
return Json(jsonData, JsonRequestBehavior.AllowGet);
}

这里我只得到首页记录。我有更多页面。搜索功能运行良好。问题是我只是首页记录。没有得到其他页面记录。我怎样才能得到另一页记录。请帮忙。

最佳答案

如果您使用 loadonce:true,jqGrid 在第一次从网格加载数据后将数据类型参数更改为“local”。所有下一次网格重新加载(排序、分页、过滤)都在本地进行。如果您想再次从服务器刷新网格数据,您应该将数据类型设置为其原始值('json' 或 'xml')。例如:

$("#pendingAppgrid").setGridParam({datatype:'json', page:1}).trigger('reloadGrid');

请访问http://www.trirand.com/jqgridwiki/doku.php?id=wiki:options有关 jqGrid 选项的更多详细信息。

关于asp.net-mvc - loadonce :true in jqGrid 时分页不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17228661/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com