<%@ page pageEncoding="UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jqGrid Demos</title>
<link rel="stylesheet" type="text/css" media="screen" href="<%=application.getContextPath()%>/resources/jqcss/jquery-ui-1.8.12.custom.css" />
<link rel="stylesheet" type="text/css" media="screen" href="<%=application.getContextPath()%>/resources/jqcss/ui.jqgrid.css" />
<link rel="stylesheet" type="text/css" media="screen" href="<%=application.getContextPath()%>/resources/jqcss/ui.multiselect.css" />
<script src="<%=application.getContextPath()%>/resources/js/jquery-1.4.2.min.js" type="text/javascript" ></script>
<script src="<%=application.getContextPath()%>/resources/jqgrid/grid.locale-cn.js" type="text/javascript"></script>
<script type="text/javascript">
$.jgrid.no_legacy_api = true;
$.jgrid.useJSON = true;
</script>
<script src="<%=application.getContextPath()%>/resources/jqgrid/jquery.jqGrid.min.js" type="text/javascript"></script>
<script src="<%=application.getContextPath()%>/resources/jqgrid/jquery-ui-1.8.12.custom.min.js" type="text/javascript"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("#list4").jqGrid({
url:"Jqgrid.jsp",
mtype: "GET",
datatype: "json",
height: 250,
colNames:['序号','日期', '姓名', '数量A','数量B','总和','备注'],
colModel:[
{name:'id',index:'id', width:30, sorttype:"int"},
{name:'invdate',index:'invdate', width:90, sorttype:"date"},
{name:'name',index:'name', width:100},
{name:'amount',index:'amount', width:80, align:"right",sorttype:"float"},
{name:'tax',index:'tax', width:80, align:"right",sorttype:"float"},
{name:'total',index:'total', width:80,align:"right",sorttype:"float"},
{name:'note',index:'note', width:150, sortable:false}
],
rowNum:4,
rowList:[4,8,12],
pager: '#pager2',
multiselect: true,
caption: "Manipulating Array Data"
});
// var mydata = [
// {id:"1",invdate:"2007-10-01",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
// {id:"2",invdate:"2007-10-02",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
// {id:"3",invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"},
// {id:"4",invdate:"2007-10-04",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
// {id:"5",invdate:"2007-10-05",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
// {id:"6",invdate:"2007-09-06",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"},
// {id:"7",invdate:"2007-10-04",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
// {id:"8",invdate:"2007-10-03",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
// {id:"9",invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"}
// ];
// for(var i=0;i<=mydata.length;i++){
// jQuery("#list4").jqGrid('addRowData',i+1,mydata[i]);
// }
});
</script>
</head>
<body>
<table id="list4"></table>
<div id="pager2"></div>
</body>
package hr.recruit.views.info;
import java.util.Map;
public class test {
public void onLoad(Map request, Map session) {
StringBuilder sb = new StringBuilder();
sb.append("[{id:").append('"').append("1").append('"')
.append(",invdate:").append('"').append("2007-10-01").append('"')
.append(",name:").append('"').append("test").append('"')
.append(",note:").append('"').append("note").append('"')
.append(",amount:").append('"').append("200.00").append('"')
.append(",tax:").append('"').append("10.00").append('"')
.append(",total:").append('"').append("210.00").append('"')
.append("}]")
;
request.put("list", sb.toString());
}
}
package hr.recruit.views.info;
import hr.recruit.util.BeanUtil;
import java.util.Map;
public class Jqgrid {
public String onLoad(Map request, Map session) {
StringBuilder sb = new StringBuilder();
sb.append("{total:").append('"').append("1").append('"')
.append(",page:").append('"').append("1").append('"')
.append(",records:").append('"').append("1").append('"')
.append(",rows:")
.append("[{id:").append('"').append("1").append('"').append(",cell:")
.append("[").append('"').append("1").append('"')
.append(",").append('"').append("2007-09-01").append('"')
.append(",").append('"').append("dxb").append('"')
.append(",").append('"').append("note3").append('"')
.append(",").append('"').append("400.00").append('"')
.append(",").append('"').append("400.00").append('"')
.append(",").append('"').append("430.00").append('"')
.append("]")
.append("}]}");
BeanUtil.responseAjax(sb.toString());
return "ajax";
}
}
|