0

我这里有一些遗留代码,我正在使用 jqGrid 来对一些 XML 数据进行分页。XML 包含 354 条记录,其中的前 20 条在页面加载后立即显示,但是 jqGrid 不显示链接以浏览其他记录并对其进行分页。

我确信 jqGrid 正在获取完整的 XML,它甚至说Viewing 1 - 20 of 354,但并没有真正让我分页。

如果我输入分页编号(例如,第 2 页的“2”)并输入它,它会发出一个 HTTP 请求(返回200状态)并且什么都不做!

这是分页的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"
            }
        },
    });
});​

如果您知道可能导致此错误的原因,请告诉我。

4

1 回答 1

0

我建议gridComplete在您的网格定义中添加一个函数,然后您将能够轻松检查一些控制分页的值:

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

这是它们都记录在案的地方:

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

于 2012-08-02T03:28:20.780 回答