日期:2014-05-16  浏览次数:20797 次

jqgrid 加载本地json加载不成功
本帖最后由 showbo 于 2012-10-29 11:25:42 编辑
大家帮我看下   谢谢了  。



html页面:



<html><head>
<link href="css/ui.jqgrid.css" rel="stylesheet" type="text/css" />
<link href="css/jquery-ui-1.8.18.custom.css" rel="stylesheet" type="text/css" />
 
<script src="js/jquery.js" type="text/javascript"> </script>
<script src="js/jquery-ui-1.8.18.custom.min.js" type="text/javascript"> </script>
<script src="js/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="js/jquery.jqGrid.min.js" type="text/javascript"> </script>

</head>
<body>
<table id="grid">
</table>


<div id="pager">
</div>


<script type="text/javascript">
$(function(){
 jQuery("#grid").jqGrid({
width:930,
   
dataType:'json',
url:'json.txt',
colNames:["id","no","name"],
colModel:
[
{name:"id",index:"id",align:'left'},
    {name:"no",index:"no",align:'left'},
{name:"name",index:"name",align:'left'}
],
viewrecords:true,  
    rowNum:4,
rowList:[4,5,6],  
jsonReader:{  
            root: "rows",   
            page: "12",   
            total: "total",   
            records: "records",   
            repeatitems: false   
        },  
pager:"#pager"
 });
  
}); 
</script>
</body>

</html>

---------------------------

json.txt



    "rows":[ 
  {"id":"01","no":"001","name":"sky1"},
  {"id":"02","no":"002","name":"sky23"},
  {"id":"03","no":"003","name":"sky456"}
  ]
    }



------解决方案--------------------
width:930,
   
//dataType:'json',//大小写没区分
  datatype:'json',
url:'json.txt',