如果使用服务器端分页,如何在JQGrid中设置总页面数?
我是JQGrid的新手,目前正在学习分页。我正在尝试实现服务器端分页 我有45张唱片。由于服务器端根据页面大小返回指定页面的请求记录如10所示,因此在单击“下一步”按钮后,“我的寻呼机”立即更改为1。我无法继续浏览更多页面,因为现在总页面数为1。根据当前记录自动计算总页数。那么,在这种情况下,如何管理总页数值呢如果使用服务器端分页,如何在JQGrid中设置总页面数?,jqgrid,jqgrid-asp.net,Jqgrid,Jqgrid Asp.net,我是JQGrid的新手,目前正在学习分页。我正在尝试实现服务器端分页 我有45张唱片。由于服务器端根据页面大小返回指定页面的请求记录如10所示,因此在单击“下一步”按钮后,“我的寻呼机”立即更改为1。我无法继续浏览更多页面,因为现在总页面数为1。根据当前记录自动计算总页数。那么,在这种情况下,如何管理总页数值呢 $("#jqGridOutbox").jqGrid({ datatype: 'json', mtype: 'POST',
$("#jqGridOutbox").jqGrid({
datatype: 'json',
mtype: 'POST',
colNames: ['Title', 'Submitted By', 'Assigned To', 'Submitted On', 'History', 'WorkFlow Name'],
colModel: [
{ name: 'TitleOut', index: 'Title', width: 173, sortable: true, search: true, formatter: ShowItemFormatterOutbox },
{ name: 'CreatedByOut', index: 'CreatedBy', width: 173, sortable: true, searchoptions: {} },
{ name: 'PendingOnOut', index: 'PendingOn', width: 173, sortable: true, searchoptions: {} },
{ name: 'CreatedOnOut', index: 'CreatedOn', width: 173, sortable: true, searchoptions: {} },
{ name: 'HistoryOut', index: 'History', width: 80, sortable: false, search: false, formatter: ViewHistoryFormatter },
{ name: 'WorkFlowNameOut', index: 'WorkFlowName', width: 170, sortable: true, search: true }
],
datatype: function (postData) { getDataOutBox(postData, OutMode, OutPageNumber); },
ajaxGridOptions: { contentType: "application/json" },
loadonce: 'false',
viewrecords: 'true',
width: 987,
viewsortcols: [true, 'vertical', true],
height: 250,
rowList: [2, 5, 10, 20, 30, 100],
hidegrid: 'false',
rowNum: 2,
autowidth: true,
gridview: true,
shrinkToFit: false,
showQuery: 'true',
jsonReader: {
root: "rows",
page: "page",
total: "total",
records: "records",
cell: "cell",
id: "Title",
userdata: "userdata",
repeatitems: true
},
gridComplete: function () {
$("#load_jqGridOutbox").hide();
$("tr.jqgrow:odd").css("background", "white");
$("tr.jqgrow:even").css("background", "#f7f7f7");
},
pager: '#jqGridOutboxPager',
pagerpos: 'center'
});
映射到数据类型的函数是GetDataOutBox
function getDataOutBox(pdata, mode, pageNumber) {
var params = new Object();
params.page = pdata.page;
params.pageSize = pdata.rows;
params.sortIndex = pdata.sidx;
params.sortDirection = pdata.sord;
params.Title = $("#gs_TitleOut").val() == undefined ? '' : $("#gs_TitleOut").val();
params.CreatedBy = $("#gs_CreatedByOut").val() == undefined ? '' : $("#gs_CreatedByOut").val();
params.PendingOn = $("#gs_PendingOnOut").val() == undefined ? '' : $("#gs_PendingOnOut").val();
params.CreatedOn = $("#gs_CreatedOnOut").val() == undefined ? '' : $("#gs_CreatedOnOut").val();
params.WorkFlowName = $("#gs_WorkFlowNameOut").val() == undefined ? '' : $("#gs_WorkFlowNameOut").val();
params.mode = mode;
params.pageNumber = pageNumber;
$("#load_jqGridOutbox").show();
$.ajax({
url: 'ClaySysWorkFlowDashBoard.aspx/GetOutboxData',
type: "POST",
contentType: "application/json; charset=utf-8",
data: JSON.stringify(params),
dataType: "json",
success: function (data, st) {
if (st == "success") {
var grid = $("#jqGridOutbox")[0];
grid.addJSONData(data.d);
//$("#jqGridOutbox")[0].updatepager(false, true);
}
},
error: function () {
alert("An error has occured retrieving the data!");
}
});
}
返回的模型是
public class JQGrid
{
public class Row
{
public int id { get; set; }
public List<string> cell { get; set; }
public Row()
{
cell = new List<string>();
}
}
public int page { get; set; }
public int total { get; set; }
public int records { get; set; }
public List<Row> rows { get; set; }
public JQGrid()
{
rows = new List<Row>();
}
}
根据页码,我只选择相应的一组10条记录。因此,返回该值后,总页数变为1。显示代码。如果可能的话,你到目前为止做了什么now@AsifRaza添加了我的代码进度asif。确保public int page{get;set;}public int total{get;set;}public int records{get;set;}public List rows{get;set;}具有正确的值。根据我的猜测,page包含实际页码,total包含总计数,records保存当前选定的记录计数,以及包含记录集的行。在我的例子中,考虑页面大小2。从第1页开始,如果单击“下一步”,则页面值为2,总计为8,记录数为2,行数为3和4条记录。