Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 分页在JQGrid上不起作用_Jquery_Asp.net Mvc_Jqgrid_Pagination - Fatal编程技术网

Jquery 分页在JQGrid上不起作用

Jquery 分页在JQGrid上不起作用,jquery,asp.net-mvc,jqgrid,pagination,Jquery,Asp.net Mvc,Jqgrid,Pagination,我正在尝试在jqgrid中进行分页。 这是我的密码: <div> <table id="JQGridDemo"></table> <div id="jqFooter" style="text-align:center;"></div> </div> <script type="text/javascript" language="javascript"> $(document).ready(fu

我正在尝试在jqgrid中进行分页。 这是我的密码:

<div>
    <table id="JQGridDemo"></table>
    <div id="jqFooter" style="text-align:center;"></div>
</div>

<script type="text/javascript" language="javascript">
$(document).ready(function () {
    $('#JQGridDemo').jqGrid({
        url: '@Url.Action("JQGrid")',
        datatype: "json",
        mtype: "post",
        colNames: ['ID', 'Name', 'Model', 'Cost', 'Date'],
        colModel: [{
            name: 'ID',
            index: 'ID'
        }, {
            name: 'Name',
            index: 'Name'
        }, {
            name: 'Model',
            index: 'Model'
        }, {
            name: 'Cost',
            index: 'Cost'
        }, {
            name: 'Date',
            width: '464px',
            index: 'Date'
        }],
        height: '100%',
        autowidth: true,
        shrinkToFit: false,
        pager: "#jqFooter",
        rowNum: 10,
        sortName: 'Name',
        viewRecords: true,
        sortorder: "asc",
        loadonce: true,
        jsonReader: {
            root: "rows",
            page: "page",
            total: "total",
            records: "records",
            repeatitems: false,
            cell: "cell",
            id: "ID",
            userdata: "userdata"
        }
    });
});
</script>   

有人能告诉我为什么分页不适合我吗???

我使用的JqGrid对我来说很好,希望它能帮助你找到问题所在

  • 确保已加载Jquery必需的文件
  • 确保已加载Grid.locale文件
  • 如果你仍然无法在Google Chrome中获得分页调试,请查看控制台选项卡。如果你遗漏了任何内容,你会发现错误

    `

    
    

    
    

看着Gowtham的回答,我能理解我做错了什么。 我正在处理一种返回,json对象位于变量内部。我希望这能为其他用户澄清

My JSON:[状态:'ok',对象:{currpage:1,TotalPage:3,totalrecords:30,行:{…}]


我没有看到代码中有任何明显的错误。可以对其进行改进,但分页应该有效。“分页不起作用”这句话到底是什么意思?您的退货数量是多少?是否超过10(请参见
rowNum
)?寻呼机中的“下一页”(“>”)按钮是否已启用?单击时是否有任何错误消息?我有六条记录..我将rownum更改为5。前5条记录显示在第1页。当我单击“下一页”按钮时,它不会进入下一页。你是否应该告诉我的控制器代码是否正确(var jsonData=new{total=6,page=page,records=gridDetail.Count,rows=gridDetail)如果使用
loadonce:true
,则将忽略
total
页面
记录
。只需使用
返回Json((从entities.Brands select list中的列表)。ToList(),JsonRequestBehavior.AllowGet)
直接。如果您将问题附加到服务器返回的JSON响应中,则可以重现您描述的问题。如果IE(按F12键启动),您可以使用或开发人员工具获得确切的服务器响应。是的,正确..我添加了loadonce:true..现在它可以工作了。
public JsonResult JQGrid() {
     AssignmentEntities entities = new AssignmentEntities();
     var gridDetail = (from list in entities.Brands select list).ToList();
     var jsonData = new {
         total = 6, page = page, records = gridDetail.Count, rows = gridDetail
     };
     return Json(jsonData, JsonRequestBehavior.AllowGet);
 }
jQuery(document).ready(function() { jQuery("#list").jqGrid({ url: '/EmployeeWiseReport/GetGridData/', datatype: 'json', mtype: 'GET', width: 600, colNames: ['Employee Id', 'UserName', 'MobileNo', 'EmailId', 'NOofChild', 'ChildName'], colModel: [ { name: 'UserId', index: 'UserId', align: 'left' }, { name: 'UserName', index: 'UserName', align: 'left' }, { name: 'MobileNo', index: 'MobileNo', align: 'left' }, { name: 'EmailId', index: 'EmailId', align: 'left' }, { name: 'NOofChild', index: 'NOofChild', align: 'left' }, { name: 'ChildName', index: 'ChildName', align: 'left' }

        ],
        jsonReader: {
            repeatitems: false,
            root: function(obj) { return obj; },
            page: function(obj) { return 1; },
            total: function(obj) { return 1; },
            records: function(obj) { return obj.length; }
        },
        loadonce: true,
        pager: jQuery('#pager'),
        rowNum: 10,
        rowList: [5, 10, 20, 50],
        sortname: 'UserId',
        sortorder: "asc",
        viewrecords: false,
        caption: 'Employee Wise Report Information'
    }).navGrid(pager, { edit: false, add: false, del: false, refresh: true, search: false });
});
  <table id="list" class="scroll" style="height: 250px; width: 550px;" cellpadding="0"
cellspacing="0" width="80%">
 <table id="pager" class="scroll" style="text-align: center;">
 </table>
jsonReader: {
                page: "obj.currpage",
                total: "obj.totalpages",
                records: "obj.totalrecords",
                repeatitems: false,
                root: "obj.rows",
                cell: "cell",
                id: "0"
            },