jqGrid不显示分页总页数

1.前端代码

<script>

$(function () {
gridList();
})
function gridList() {
  var $gridList = $("#gridList");
  $gridList.dataGrid({
    url: "/AgentManage/Agent/GetGridJson",
    height: $(window).height() - 128,
    colModel: [
    { label: '主键', name: 'F_Id', hidden: true },
    { label: '姓名', name: 'F_Name', width: 150, align: 'left' },
    {label: '学校', name: 'F_SchoolName', width: 200, align: 'left'},
    {label: '联系方式', name: 'F_Mobile', width: 100, align: 'left',},
    {
      label: '认证状态', name: 'F_AuthStatus', width: 150, align: 'left',
      formatter: function (cellvalue) {
        return cellvalue == 1
          ? "已认证"
          : "未认证";
      }
    },
    {label: '银行', name: 'F_Acount', width: 150, align: 'left',},
    {label: '银行卡号', name: 'F_BankNum', width: 150, align: 'left',}, 

    {
      label: '操作',
      name: 'F_Count',
      width: 200,
      align: 'center',
      sortable: false,
      formatter: function (value) {
        var html = "<label style='color:#10d8b2;cursor: pointer;' class='re_num'>注册人数</label>&nbsp;&nbsp;&nbsp;<label class='buy_num' style='color:#a94442;cursor:     pointer;'>购买人数</label>";
        return html;
      }
    }
  ],
  pager: "#gridPager",
  sortname: 'F_CreatorTime desc',
  viewrecords: true,
  jsonReader: {
    page: "page",
    total: "total",
    records: "records"
  }
});
$("#btn_search").click(function () {
  $gridList.jqGrid('setGridParam', {
    postData: {
      keyword: $("#txt_keyword").val()
    }
  }).trigger('reloadGrid');
});

}

</script>

<div class="gridPanel">
  <table id="gridList"></table>
  <div id="gridPager"></div>
</div>

2.后台代码

[HttpGet]
[HandlerAjaxOnly]
public ActionResult GetGridJson(Pagination pagination, string keyword)
{
  var data = serviceApp.GetListByPage(pagination, keyword);
  var datelist = new { page=pagination.page ,total=pagination.total, records=pagination.records, rows= data };
  return Content(datelist.ToJson());
}

3.说明

前端增加

jsonReader: {
    page: "page", //当前页
    total: "total",//总页数
    records: "records"// 总记录数
  }

后台对应返回参数(用rows返回数据才行)

var datelist = new { page=pagination.page ,total=pagination.total, records=pagination.records, rows= data };

上一篇:Python数组操作将一维数组编程二维数组


下一篇:Kafka消费者源码解析之二Fetcher