有人可以帮助我并指出我哪里出错了。感谢你的帮助。网格显示空白并且没有加载任何内容。
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.min.js"></script>
<script type="text/javascript" src="http://www.ok-soft-gmbh.com/jqGrid/jquery.jqGrid-4.1.1/js/i18n/grid.locale-en.js"></script>
<script type="text/javascript">
$.jgrid.no_legacy_api = true;
$.jgrid.useJSON = true;
</script>
<script type="text/javascript" src="http://www.ok-soft-gmbh.com/jqGrid/jquery.jqGrid-4.1.1/js/jquery.jqGrid.src.js"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("#list2").jqGrid({
url:'http://localhost/jqgrid/book.php',
datatype: "json",
colNames:['Title', 'Author', 'Publisher'],
colModel:[
{name:'title' , width:160},
{name:'author' ,width:180},
{name:'publisher' ,width:80}
],
rowNum:10,
rowList:[10,20,30],
pager: '#pager2',
sortname: 'title',
sortorder: "desc",
height: 'auto',
width: 900,
viewrecords: true,
gridview: true,
caption:"JSON Example",
jsonReader : {
repeatitems: true,
cell: "cell",
id:"id",
userdata: "userdata",
root: "rows",
page: "page",
total: "total",
records: "records"
}
});
jQuery("#list2").jqGrid('navGrid','#pager2',{edit:false,add:true,del:true});
});
</script>
</head>
<body>
<table id="list2"><tr><td></td></tr></table>
<div id="pager2"></div>
</body>
</html>
这是我来自 PHP 的 JSON 响应:
{"page":"1","total":1,"records":"2","rows":[{"id":"2","cell":["PHP QUERY","JSON" ,"VTECH"]},{"id":"1","cell":["JQUERY Cook book","MY AUTHOR","GRID"]}]}