80319f5c04f055b2222371f5e0c8fed1e5f5f0b4.svn-base 5.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
  2. <%
  3. String path = request.getContextPath();
  4. %>
  5. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  6. <html xmlns="http://www.w3.org/1999/xhtml">
  7. <head>
  8. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  9. <title>数据分组</title>
  10. <!--框架必需start-->
  11. <script type="text/javascript" src="<%=path%>/libs/js/jquery.js"></script>
  12. <script type="text/javascript" src="<%=path%>/libs/js/language/cn.js"></script>
  13. <script type="text/javascript" src="<%=path%>/libs/js/framework.js"></script>
  14. <link href="<%=path%>/libs/css/import_basic.css" rel="stylesheet" type="text/css"/>
  15. <link rel="stylesheet" type="text/css" id="skin" prePath="<%=path%>/"/>
  16. <link rel="stylesheet" type="text/css" id="customSkin"/>
  17. <!--框架必需end-->
  18. <!--数据表格start-->
  19. <script src="<%=path%>/libs/js/table/quiGrid.js" type="text/javascript"></script>
  20. <!--数据表格end-->
  21. </head>
  22. <body>
  23. <div class="box1">
  24. 分组时只能对已经加载的数据分组。第二个例子,在分组时对每组数量做了统计,并设置了更个性化的分组效果。
  25. </div>
  26. <div class="padding_right5">
  27. <div id="grid1"></div>
  28. </div>
  29. <div class="padding_right5">
  30. <div id="grid2"></div>
  31. </div>
  32. <script type="text/javascript">
  33. var grid1 = null;
  34. var grid2 = null;
  35. //定义本地数据
  36. var gridData={"form.paginate.pageNo":1,"form.paginate.totalRows":13,"rows":[
  37. {"deptName":"部门1","sex":"女","remark":"好啊","hobby":["唱歌"],"beginworkDate":"2012-06-13 00:00:00.0","photo":null,"version":null,"id":125,"degree":"硕士结业","age":20,"name":"员工1","deptId":12,"ability":5},
  38. {"deptName":"部门1","sex":"男","remark":"备注啊","hobby":["唱歌"],"beginworkDate":"2012-06-13 00:00:00.0","photo":null,"version":null,"id":124,"degree":"本科毕业","age":20,"name":"员工2","deptId":11,"ability":5},
  39. {"deptName":"部门1","sex":"男","remark":null,"hobby":["唱歌","跳舞"],"beginworkDate":"2012-06-12 00:00:00.0","photo":null,"version":null,"id":123,"degree":"本科毕业","age":20,"name":"员工3","deptId":9,"ability":5},
  40. {"deptName":"部门1","sex":"女","remark":"不错啊","hobby":["唱歌","跳舞"],"beginworkDate":"2012-06-12 00:00:00.0","photo":null,"version":null,"id":121,"degree":"硕士肄业","age":20,"name":"员工4","deptId":8,"ability":5},
  41. {"deptName":"部门1","sex":"男","remark":null,"hobby":["唱歌","跳舞"],"beginworkDate":"2012-06-12 00:00:00.0","photo":null,"version":null,"id":120,"degree":"博士肄业","age":20,"name":"员工5","deptId":7,"ability":5},
  42. {"deptName":"部门2","sex":"女","remark":null,"hobby":["唱歌","跳舞"],"beginworkDate":"2012-06-05 00:00:00.0","photo":null,"version":null,"id":119,"degree":"博士肄业","age":20,"name":"员工6","deptId":6,"ability":5},
  43. {"deptName":"部门2","sex":"女","remark":null,"hobby":["唱歌","跳舞"],"beginworkDate":"2012-06-05 00:00:00.0","photo":null,"version":null,"id":119,"degree":"博士肄业","age":20,"name":"员工7","deptId":6,"ability":5},
  44. {"deptName":"部门2","sex":"女","remark":null,"hobby":["唱歌","跳舞"],"beginworkDate":"2012-06-05 00:00:00.0","photo":null,"version":null,"id":119,"degree":"博士肄业","age":20,"name":"员工8","deptId":6,"ability":5},
  45. {"deptName":"部门2","sex":"女","remark":null,"hobby":["唱歌","跳舞"],"beginworkDate":"2012-06-05 00:00:00.0","photo":null,"version":null,"id":119,"degree":"博士肄业","age":20,"name":"员工9","deptId":6,"ability":5},
  46. {"deptName":"部门2","sex":"女","remark":null,"hobby":["唱歌","跳舞"],"beginworkDate":"2012-06-05 00:00:00.0","photo":null,"version":null,"id":119,"degree":"博士肄业","age":20,"name":"员工10","deptId":6,"ability":5},
  47. {"deptName":"部门2","sex":"女","remark":null,"hobby":["唱歌","跳舞"],"beginworkDate":"2012-06-05 00:00:00.0","photo":null,"version":null,"id":119,"degree":"博士肄业","age":20,"name":"员工11","deptId":6,"ability":5},
  48. {"deptName":"部门2","sex":"女","remark":null,"hobby":["唱歌","跳舞"],"beginworkDate":"2012-06-05 00:00:00.0","photo":null,"version":null,"id":119,"degree":"博士肄业","age":20,"name":"员工12","deptId":6,"ability":5}
  49. ]}
  50. function initComplete(){
  51. //不使用分组渲染
  52. grid1 = $("#grid1").quiGrid({
  53. columns: [
  54. { display: '姓名', name: 'name', align: 'center', width: "25%"},
  55. { display: '性别', name: 'sex', align: 'center', width: "25%"},
  56. { display: '部门', name: 'deptName', align: 'center', width: "25%", isSort:false},
  57. { display: '学历', name: 'degree', align: 'center', width: "25%" }
  58. ],
  59. groupColumnName: "sex", groupColumnDisplay: "性别",
  60. data: gridData, pageSize: 10, sortName: 'id',rownumbers:true,
  61. height: '450', width:"100%"
  62. });
  63. //使用分组渲染
  64. grid2 = $("#grid2").quiGrid({
  65. columns: [
  66. { display: '姓名', name: 'name', align: 'center', width: "25%"},
  67. { display: '性别', name: 'sex', align: 'center', width: "25%"},
  68. { display: '部门', name: 'deptName', align: 'center', width: "25%", isSort:false},
  69. { display: '学历', name: 'degree', align: 'center', width: "25%" }
  70. ],
  71. groupColumnName: "sex", groupColumnDisplay: '性别',
  72. //可以使用groupColumnDisplay,也可以在return语句中自己拼语句
  73. groupRender: function(groupValue, groupData, groupColumnDisplay){
  74. if("女" == groupValue){
  75. return "<font color=red>美女" + "【共" + groupData.length + "人】</font>";
  76. }else{
  77. return "帅哥【共" + groupData.length + "人】";
  78. }
  79. },
  80. data: gridData, pageSize: 10, sortName: 'id',rownumbers:true,
  81. height: '450', width:"100%"
  82. });
  83. }
  84. </script>
  85. </body>