我已经将数据从Web服务提取到客户端,最初我将其显示在警告框中,但现在我需要以jqGrid表示显示数据,请检查我的代码是否需要更改任何内容。
<head id="head1" runat="server">
<title></title>
<script src="Scripts/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="Scripts/grid.local-en.js" type="text/javascript"></script>
<script src="Scripts/jquery.jqgrid.min.js" type="text/javascript"></script>
<link href="Scripts/jqgrid/jqgrid.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
jQuery(document).ready(function()
{
jQuery("#grid").jqGrid({
url:"Name.asmx/Display",
datatype:"json",
type:'GET',
colNames:['eid', 'ename', 'dob', 'addr', 'pincode', 'dsgid', 'salary', 'doj'],
colModel:[
{ name: 'eid', index: 'id', width: 55, sortable: false, editable: false, editoptions: { readonly: true, size: 10} },
{ name: 'ename', index: 'ename', width: 200, editable: false },
{ name: 'dob', index: 'dob', width: 200, editable: true },
{ name: 'addr', index: 'addr', width: 100, editable: true },
{ name: 'pincode', index: 'pincode', width: 300, editable: true },
{ name: 'type', index: 'type', width: 200, editable: true},
{ name: 'dsgid', index: 'dsgid', width: 200, editable: true },
{ name: 'salary', index: 'salary', width: 100 },
{ name: 'doj', index: 'doj', width: 100 },
],
jsonReader: {
repeatitems: false
},
rowNum: 10,
rowList: [10, 20, 30],
pager: jQuery('#gridpager'),
sortname: 'ename',
viewrecords: true,
loadonce:true,
sortorder: "asc",
caption: "customerdetails",
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2>
AJAX call test page</h2>
<div id="jqgrid">
<table id="grid">
</table>
<div id="gridpager">
</div>
</div>
</div>
</form>
</body>
</html>
答案 0 :(得分:0)
我在网格中找不到任何错误。猜错误可能来自某些脚本文件或来自json数据u返回。
<link href="Scripts/jqgrid/jqgrid.css" rel="stylesheet" type="text/css" /
是错误的错误吗?请检查 json ,使用json validator返回有效。并检查格式Json Data retrieve