ea67b603e64078cd5855f51d85439b499fe2b07d.svn-base 5.8 KB

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