내 데이터를 표시하기 위해 jqGrid를 가져 오는 데 문제가 있습니다. 헤더를 클릭하면 테이블의 하단을 볼 수있는 레코드가 표시되지만 사실이 아님을 압니다. 표시하려는 Json은 URL에서 가져온 것이므로 URL의 Json은 golang을 사용하여 mysql 데이터베이스에서 가져온 것입니다. 나는 Jquery jqGrid 버전 4.4.3을 사용하고있다.jqGrid에 데이터가 없습니다.
이 테이블과 기능을 표시하는 코드 내 HTML 페이지는
<!DOCTYPE html>
<html lang="en">
<head>
<script type="text/ecmascript" src="jquery/js/jquery-1.7.2.min.js"></script>
<script type="text/ecmascript" src="jquery/js/i18n/grid.locale-en.js"></script>
<script type="text/ecmascript" src="jquery/js/jquery.jqGrid.min.js"></script>
<link rel="stylesheet" type="text/css" media="screen" href="jquery/css/ui.jqgrid.css"/>
<link rel="stylesheet" type="text/css" media="screen" href="jquery/css/jquery-ui.css" />
<meta http-equiv="content-type" content="text/html" charset="UTF-8">
<title>IPAM</title>
</head>
<body>
<table id="jqGrid"></table>
<div id="jqGridPager"></div>
<script type="text/javascript">
$(document).ready(function() {
$("#jqGrid").jqGrid({
url:'http://localhost:1323/api/v1/leases',
mtype: "GET",
datatype: 'jsonString',
jsonReader:{
repeatitems: false,
id: "address",
},
colModel: [
{label: 'address', index:'address', key: true, width: 100},
{label: 'client_id', name:'client_id', width: 150},
{label: 'expire', name:'expire', width: 150},
{label: 'fqdn_fwd', name:'fqdn_fwd', width: 150},
{label: 'fqdn_rev', name:'fqdn_rev', width: 150},
{label: 'hostname', name:'hostname', width: 150},
{label: 'hwaddr', name:'hwaddr', width: 150},
{label: 'state', name:'state', width: 150},
{label: 'subnet_id', name:'subnet_id', width: 150},
{label: 'valid_lifetime', name:'valid_lifetime', width: 150},
],
page: 1,
scroll: 1,
viewrecords: true,
width: 780,
height: 250,
rowNum: 20,
pager: "#jqGridPager"
});
});
</script>
</body>
</html>
이는 URL에 MySQL의 DB에서 가져온 및 표시되는 JSON 내가
([{"address":"178795010","client_id":null,"expire":"2016-09-26 16:56:32","fqdn_fwd":"1","fqdn_rev":"1","hostname":"vagrant-20009.ipam.bskyb","hwaddr":"0800272022E6","state":"0","subnet_id":"500","valid_lifetime":"4000"},{"address":"178795011","client_id":null,"expire":"2016-09-26 16:58:48","fqdn_fwd":"1","fqdn_rev":"1","hostname":"vagrant-18992.ipam.bskyb","hwaddr":"0800270FB593","state":"0","subnet_id":"500","valid_lifetime":"4000"},{"address":"178795012","client_id":null,"expire":"2016-09-26 17:13:55","fqdn_fwd":"1","fqdn_rev":"1","hostname":"dhcp-client1.ipam.bskyb","hwaddr":"0800275EA5B9","state":"0","subnet_id":"500","valid_lifetime":"4000"},{"address":"178795013","client_id":null,"expire":"2016-09-26 16:56:17","fqdn_fwd":"1","fqdn_rev":"1","hostname":"vagrant-10873.ipam.bskyb","hwaddr":"0800275FCA93","state":"0","subnet_id":"500","valid_lifetime":"4000"},{"address":"178795018","client_id":null,"expire":"2016-09-26 17:06:16","fqdn_fwd":"1","fqdn_rev":"1","hostname":"vagrant-24830.ipam.bskyb","hwaddr":"080027707E62","state":"0","subnet_id":"500","valid_lifetime":"4000"},{"address":"3232250120","client_id":null,"expire":"2016-09-26 16:17:15","fqdn_fwd":"1","fqdn_rev":"1","hostname":"bobtheblob7.ipam.bmarkskyb","hwaddr":"080027063AD9","state":"0","subnet_id":"12","valid_lifetime":"100"},{"address":"3232250122","client_id":null,"expire":"2016-09-26 16:17:22","fqdn_fwd":"1","fqdn_rev":"1","hostname":"bobtheblob8.ipam.bmarkskyb","hwaddr":"800027A5E27A","state":"0","subnet_id":"12","valid_lifetime":"100"}]);
를 호출하고있다
당신이 ** 같은 웹 사이트에서 데이터 **를 사용하려고합니까? 이 경우 URL에서 'http : // localhost : 1323' 접두어를 제거해야합니다. 다음 문제 :'datatype : 'jsonString'이 잘못되었습니다. 서버에서 데이터를로드하면'datatype : 'json''을 사용해야합니다. 'scroll : 1'의 사용은 권장하지 않지만'loadonce : true'는 아마 당신이 필요로하는 것일 것입니다. 또 다른 권장 사항 : 오랜 시간 이후 지원되지 않는 레트로 버전 4.4.3을 사용하지 마십시오. 나는 4.4.3과 호환되는 jqGrid의 [free jqGrid] (https://github.com/free-jqgrid/jqGrid) 포크를 개발한다. 무료 jqGrid로 업그레이드하는 것이 좋습니다 – Oleg
무료 jqGrid 사용의 첫 번째 단계는 [here] (http://free-jqgrid.github.io/getting-started/index.html)를 참조하십시오. [위키] (https://github.com/free-jqgrid/jqGrid/wiki)와 모든 게시 된 버전에 대한 추가 정보는 추가 정보를 제공합니다. – Oleg
@Oleg 조언을 주셔서 감사합니다. 지금 브라우저에서 페이지를로드 할 때이 오류가 발생합니다. parsererror : 오류 : jQuery112402678749294365155_1475059615993이 호출되지 않았습니다. 200 성공 – computerNoob