简体   繁体   English

jqGrid不显示分页链接

[英]jqGrid not displaying pagination links

I have some legacy code here and I am using jqGrid in order to paginate some XML data. 我这里有一些旧代码,我正在使用jqGrid来分页一些XML数据。 The XML contains 354 record and the first 20 of them are displayed as soon as the page loads, but then jqGrid does not display the links to browse the other records and paginate them. XML包含354条记录,并且在页面加载后立即显示其中的前20条记录,但是jqGrid不显示链接以浏览其他记录并对其进行分页。

I am sure jqGrid is getting the full XML and it even says Viewing 1 - 20 of 354 , but doesn't really let me paginate. 我确信jqGrid会获取完整的XML,甚至说Viewing 1 - 20 of 354 ,但实际上并没有让我分页。

And if I enter the number of the pagination ("2" for page 2, for example) and enter it, it makes an HTTP request (which returns 200 status) and does nothing! 如果输入分页号(例如,第2页为“ 2”)并输入它,它将发出HTTP请求(返回200状态),并且什么也不做!

This is the JS code for the pagination: 这是分页的JS代码:

$(document).ready(function() {
    erc_id = $('#erc_id').val();

    jQuery("#list4").jqGrid({
        url: "/ercs/" + erc_id + "/exemplares.xml",
        datatype: "xml",
        width: 650,
        pager: "gridPager",
        height: 'auto',
        xmlReader: {
            root: "exemplares",
            row: "exemplar",
            repeatitems: false,
            id: "id"
        },
        colNames: ['Código', 'Referência', 'Num. Controle', 'Dt. Moldagem', 'Traço'],
        colModel: [
            {
            name: 'codigo',
            index: 'codigo',
            width: 60,
            sortable: false},
        {
            name: 'referencia',
            index: 'referencia',
            width: 160,
            sortable: false},
        {
            name: 'numero-controle',
            index: 'numero-controle',
            width: 60,
            sortable: false,
            align: 'center'},
        {
            name: 'data-moldagem',
            index: 'data-moldagem',
            width: 60,
            sortable: false},
        {
            name: 'traco',
            index: 'traco',
            width: 60,
            sortable: false,
            xmlmap: "traco>reference"},
            ],
        viewrecords: true,
        caption: "Exemplares",
        subGrid: true,
        subGridRowExpanded: function(subgrid_id, row_id) {
            var subgrid_table_id = subgrid_id + "_t";
            my_row_id = row_id
            $("#" + subgrid_id).html("<table id='" + subgrid_table_id + "' class='scroll'></table>");
            row_id = row_id.replace("5687", "");
            jQuery("#" + subgrid_table_id).jqGrid({
                url: "/ercs/" + erc_id + "/exemplares/" + row_id + "/cps.xml",
                datatype: "xml",
                height: 'auto',
                width: 550,
                xmlReader: {
                    root: "cps",
                    row: "cp",
                    repeatitems: false,
                    id: "id"
                },
                colNames: ['Número', 'Carga', 'Idade', 'Prensa', 'Retifica', 'Ruptura', 'retifica', 'N cont antigo'],
                colModel: [
                    {
                    name: "numero",
                    index: "numero",
                    width: 60,
                    sortable: false},
                {
                    name: "carga",
                    index: "carga",
                    width: 50,
                    sortable: false,
                    align: 'center'},
                {
                    name: "idade",
                    index: "idade",
                    width: 30,
                    sortable: false,
                    align: 'center'},
                {
                    name: "prensa",
                    index: "carga",
                    width: 30,
                    sortable: false,
                    align: 'center'},
                {
                    name: "carga",
                    index: "carga",
                    width: 50,
                    sortable: false,
                    align: 'center'},
                {
                    name: "ruptura",
                    index: "ruptura",
                    width: 50,
                    sortable: false,
                    align: 'center'},
                {
                    name: "retifica",
                    index: "retifica",
                    width: 50,
                    sortable: false,
                    align: 'center'},
                {
                    name: "numero-controle-antigo",
                    index: "numero-controle-antigo",
                    width: 50,
                    sortable: false,
                    align: 'center'}
                            ]
            });
        },
        ondblClickRow: function(id) {
            id = id.replace("5687", "");
            if (typeof my_row_id !== "undefined") {
                my_row_id = my_row_id.replace("5687", "");
                window.location = "/ercs/" + erc_id + "/exemplares/" + my_row_id + "/cps/" + id + "/edit"
            } else {
                window.location = "/ercs/" + erc_id + "/exemplares/" + id + "/edit"
            }
        },
    });
});​

If you know what is possibly causing this error please tell me. 如果您知道可能导致此错误的原因,请告诉我。

I would recommend adding a gridComplete function to your grid definition and then you'll be able to easily inspect some of the values that control paging: 我建议向您的网格定义添加gridComplete函数,然后您将能够轻松检查一些控制分页的值:

gridComplete: function(){
  var r = $(this).getGridParam('records');
  var p = $(this).getGridParam('page');
  var rec = $(this).getGridParam('reccount');
  var row = $(this).getGridParam('rowNum');
}

Here is where they are all documented: 这些都是在这里记录的:

http://www.trirand.com/jqgridwiki/doku.php?id=wiki:pager#properties http://www.trirand.com/jqgridwiki/doku.php?id=wiki:pager#properties

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM