2012-08-01 80 views
0

我在這裏有一些遺留的代碼,我使用jqGrid爲了分頁一些XML數據。 XML包含354條記錄,並且頁面加載後會立即顯示前20條記錄,但jqGrid不會顯示鏈接以瀏覽其他記錄並對它們進行分頁。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" 
      } 
     }, 
    }); 
});​ 

如果你知道什麼是可能造成此錯誤,請告訴我。

回答

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