2015-11-12 84 views
0

我有一個非常好奇的錯誤或JQuery與JqGrid的錯誤。錯誤是當我嘗試在表格中顯示JSON中的數據時,如果向我顯示數據,如果表格未顯示超過20列並且具有超過200個數據,則代碼如下所示:JQGrid的JQuery表不能顯示信息

標題是:

<!DOCTYPE html> 
<html> 
<head> 
<script src="https://code.jquery.com/jquery-2.1.4.min.js" type="text/javascript"></script> 
<script type="text/ecmascript" src="jqGrid/js/i18n/grid.locale-en.js"></script> 
<script type="text/ecmascript" src="jqGrid/js/jquery.jqGrid.min.js"></script> 
<link rel="stylesheet" type="text/css" media="screen" href="jquery-ui/jquery-ui.css" /> 
<link rel="stylesheet" type="text/css" media="screen" href="jqGrid/css/ui.jqgrid.css" /> 
<!-- Continuacion de JqGrid--> 
<!-- A link to a jQuery UI ThemeRoller theme, more than 22 built-in and many more custom --> 
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"> 
<!-- The link to the CSS that the grid needs --> 
<link rel="stylesheet" type="text/css" media="screen" href="jqGrid/css/ui.jqgrid-bootstrap.css" /> 

的JS是:

<script> 
    $.jgrid.defaults.width = 780; 
</script> 
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script> 
<meta charset="utf-8" /> 
<div style="margin-left:20px"> 
    <table id="jqGrid4"></table> 
    <div id="jqGridPager4"></div> 
</div> 
<script type="text/javascript"> 

    $(document).ready(function() { 

     $("#jqGrid4").jqGrid({ 
      url: 'http://localhost/fileupload/api/Proveedor', 
      mtype: "GET", 
      styleUI : 'Bootstrap', 
      datatype: "JSON", 
      colModel: [ 
       { label: 'id', name: 'id', key: true, width: 75 }, 
       { label: 'Name', name: 'Name', width: 150 }, 
       { label: 'RFC', name: 'RFC', width: 150 }, 
       { label: 'Company Name', name: 'CompanyName', width: 150 }, 
       { label:'DateCreation', name: 'DateCreation', width: 150 } 
      ], 
      viewrecords: true, 
      height: 250, 
      rowNum: 20, 
      pager: "#jqGridPager4", 
      sortable: true 
     }); 
    }); 

</script> 

table

在你可以看到,該表只顯示20行的形象,但我有207行。我需要箭頭移動並顯示更多行,但我不能。有任何想法嗎?我不想放rownum:+20或更多,因爲我不喜歡那個,我需要用箭頭移動,但是我不能。

+0

如何查看'/ fileupload/api/Proveedor'的響應?你是否在服務器上實現了*服務器端分頁*或者服務器一次返回所有207行,並且你想使用*客戶端分頁*?在最後一種情況下,您應該添加'loadonce:true'選項。 – Oleg

+0

這是!!!!!! @ Oleg非常感謝! –

+0

歡迎您!我寫了與答案相同的信息。通過[接受](http://meta.stackexchange.com/a/5235/147495),您的答案將會提高您的聲譽。 – Oleg

回答

1

你實現的服務器或服務器returnes所有207行上服務器端分頁一次,並要使用客戶端分頁?在最後一種情況下,您應該添加loadonce: true選項。 207行並不多,因此我建議您在場景中使用loadonce: true選項。您不需要在服務器端編寫長碼,並且可以直接使用本地數據的排序,分頁和過濾/搜索(請參見filterToolbaradvanced searching)。