2016-12-21 3 views
0

내 코드에 무엇이 누락되었는지 확실하지 않습니다. Json 데이터를로드하는 jqGrid가 있습니다. jqGrid 버전 5.2.0을 사용하고 있습니다.jqGrid가 json 데이터를로드하지 않음

아래는 내 html과 스크립트입니다.

{"page":1,"total":1,"records":10,"rows":[{"id":2432447,"cell":[2432447,1450410,57.23,"ORACLE PROJECTS",835711,3219040,"86652"]},{"id":2432451,"cell":[2432451,868512,0,"ORACLE PROJECTS",741610,3126807,"84605"]},{"id":2432453,"cell":[2432453,868512,5403.6,"ORACLE PROJECTS",741610,3126807,"84605"]},{"id":2432455,"cell":[2432455,1814091,0,"ORACLE PROJECTS",840842,3210792,"87986"]},{"id":2432456,"cell":[2432456,1814091,600,"ORACLE PROJECTS",840842,3210792,"87986"]},{"id":2432460,"cell":[2432460,841706,0,"ORACLE PROJECTS",767616,3226001,"85666"]},{"id":2432465,"cell":[2432465,1814095,0,"ORACLE PROJECTS",840842,3210293,"87986"]},{"id":2432466,"cell":[2432466,1814095,600,"ORACLE PROJECTS",840842,3210293,"87986"]},{"id":2432901,"cell":[2432901,1231634,0,"ORACLE PROJECTS",741610,3190901,"84605"]},{"id":2432915,"cell":[2432915,1231634,4651.72,"ORACLE PROJECTS",741610,3190901,"84605"]}]} 

페이지로드하지만 데이터를 다음과 같이

<!DOCTYPE html> 
<html> 
<head> 
    <meta charset="utf-8"> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge"> 
    <title>Data Grids</title> 
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"> 

<!-- Font Awesome --> 
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css"> 

<!-- jqGrid jQuery css --> 
<!-- A link to a jQuery UI ThemeRoller theme, more than 22 built-in and many more custom --> 
<link rel="stylesheet" href="../static/plugins/jqGrid/css/jquery-ui.css" /> 
<!-- The link to the CSS that the grid needs --> 
<link rel="stylesheet" href="../static/plugins/jqGrid/css/ui.jqgrid.css" /> 

<!-- jqGrid jQuery js --> 
<script type="text/javascript" src="../static/plugins/jqGrid/js/jquery-1.11.0.min.js"></script> 
<script type="text/javascript" src="../static/plugins/jqGrid/js/jquery.jqGrid.min.js"></script> 
<script type="text/javascript" src="../static/plugins/jqGrid/js/i18n/grid.locale-en.js"></script> 

</head> 
<body> 
    <table id="myGrid"></table> 
    <div id="myGridPager"></div> 

    <script type="text/javascript"> 
$(document).ready(function() { 
    $("#myGrid").jqGrid({ 
     url: "/pages/php/getGridData.php", 
     datatype: "json", 
     mtype: "GET", 
     colNames: ["Asset Number", "Cost", "Source", "Project ID", "Task ID", "PO Number"], 
     colModel: [ 
      { name: "ASSET_ID", width: 80 }, 
      { name: "FIXED_ASSETS_COST", width: 90, align: "right" }, 
      { name: "FEEDER_SYSTEM_NAME", width: 80 }, 
      { name: "PROJECT_ID", width: 80 }, 
      { name: "TASK_ID", width: 80 }, 
      { name: "PO", width: 80, sortable: false } 
     ], 
     jsonReader : { 
      root: "rows", 
      page: "page", 
      total: "total", 
      records: "records", 
      repeatitems: true, 
      id: "id", 
      cell: "cell" 
      }, 
     width: 700, 
     height: 'auto', 
     pager: "#myGridPager", 
     rowNum: 10, 
     rowList: [10, 20, 30], 
     sortname: "ASSET_ID", 
     sortorder: "desc", 
     viewrecords: true, 
     gridview: true, 
     autoencode: true, 
     caption: "Source Lines (FAR)" 
    }); 
    $("#myGrid").jqGrid('navGrid','#myGridPager',{edit:false,add:false,del:false});  
}); 
</script> 

</body> 
</html> 

JSON 데이터입니다. 내가 잘못하고있는 것이 있습니까?

답변

0

게시 한 코드에서 href 속성이 유효한 URL로 설정되지 않은 것 같습니다. 예를 들어 : <link rel="stylesheet" href="../static/plugins/jqGrid/css/jquery-ui.css" /> (마찬가지로 다른 JS 및 CSS 링크 및 스크립트 태그에 추가 링크) 아마 대부분의 문제를 해결하는 유효한 URL에 대한 링크를 변경

.

0

문제는 올바른 json 출력을 제공했지만 일부 경고 및주의 사항을 출력하는 PHP 코드 (getGridData.php)입니다.

내 PHP에서 E_WARNING 및 E_NOTICE 오류를 비활성화해야했습니다.

error_reporting(E_ERROR | E_PARSE); 

난 여전히 오류를 무시하지 말고 내 PHP 코드를 돌봐야합니다. 그러나 그동안이 방법이 효과적이었습니다.

감사의 말로 Pratyay에게 감사드립니다.