使用 pqgrid 将JSON数据转换成TABLE
使用 pqgrid 将JSON数据转换成TABLE
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<!--jQuery dependencies-->
<link rel="stylesheet" href="./jquery-ui.css" />
<script src="./jquery.js"></script>
<script src="./jquery-ui.js"></script>
<!--PQ Grid files-->
<link rel="stylesheet" href="pqgrid.min.css" />
<script src="pqgrid.min.js"></script>
<!--PQ Grid Office theme-->
<link rel="stylesheet" href="themes/office/pqgrid.css" />
<script type="text/javascript">
$(document).ready(function(){
$.ajax({
url:'http://localhost:8081/test?name=hedan',
dataType:"jsonp",
jsonp:"jsonpcallback",
success:function(data){
alert(data);
var dataObj=eval("("+data+")");//转换为json对象
var obj = { width: 700, height: 400, title: "ParamQuery Grid Example",resizable:true,draggable:true };
obj.colModel = [
{ title: "backvm", width: 200 ,dataIndx: "backvm"},
{ title: "msg",width: 200 ,dataIndx: "msg"}];
obj.dataModel = {
data: dataObj.resList,
location: "local",
sorting: "local",
paging: "local",
curPage: 1,
rPP: 1,
sortIndx: "backvm",
sortDir: "up",
rPPOptions: [1, 10, 20, 30, 40, 50, 100, 500, 1000]
};
$("#grid_array").pqGrid(obj);
}
});
});
</script>
</head>
<body>
<div id="grid_array" style="margin:100px;"></div>
</body>
</html>