简体   繁体   中英

jqGrid not displaying pagination links

I have some legacy code here and I am using jqGrid in order to paginate some XML data. 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.

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.

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!

This is the JS code for the pagination:

$(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: 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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