event.html 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <!DOCTYPE html>
  2. <html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
  3. <head>
  4. <th:block th:include="include :: header('自定义触发事件')" />
  5. </head>
  6. <body class="gray-bg">
  7. <div class="container-div">
  8. <div class="row">
  9. <div class="col-sm-12 select-table table-striped">
  10. <p class="select-title">自定义触发事件(点击某行/双击某行/单击某格/双击某格/服务器发送数据前触发/数据被加载时触发)</p>
  11. <table id="bootstrap-table"></table>
  12. </div>
  13. </div>
  14. </div>
  15. <div th:include="include :: footer"></div>
  16. <script th:inline="javascript">
  17. var prefix = ctx + "demo/table";
  18. var datas = [[${@dict.getType('sys_normal_disable')}]];
  19. $(function() {
  20. var options = {
  21. url: prefix + "/list",
  22. showSearch: false,
  23. showRefresh: false,
  24. showToggle: false,
  25. showColumns: false,
  26. onCheck: onCheck,
  27. onUncheck: onUncheck,
  28. onCheckAll: onCheckAll,
  29. onUncheckAll: onUncheckAll,
  30. onClickRow: onClickRow,
  31. onDblClickRow: onDblClickRow,
  32. onClickCell: onClickCell,
  33. onDblClickCell: onDblClickCell,
  34. responseHandler: responseHandler,
  35. onLoadSuccess: onLoadSuccess,
  36. columns: [{
  37. checkbox: true
  38. },
  39. {
  40. field : 'userId',
  41. title : '用户ID'
  42. },
  43. {
  44. field : 'userCode',
  45. title : '用户编号'
  46. },
  47. {
  48. field : 'userName',
  49. title : '用户姓名'
  50. },
  51. {
  52. field : 'userPhone',
  53. title : '用户手机'
  54. },
  55. {
  56. field : 'userEmail',
  57. title : '用户邮箱'
  58. },
  59. {
  60. field : 'userBalance',
  61. title : '用户余额'
  62. },
  63. {
  64. field: 'status',
  65. title: '用户状态',
  66. align: 'center',
  67. formatter: function(value, row, index) {
  68. return $.table.selectDictLabel(datas, value);
  69. }
  70. },
  71. {
  72. title: '操作',
  73. align: 'center',
  74. formatter: function(value, row, index) {
  75. var actions = [];
  76. actions.push('<a class="btn btn-success btn-xs" href="#"><i class="fa fa-edit"></i>编辑</a> ');
  77. actions.push('<a class="btn btn-danger btn-xs" href="#"><i class="fa fa-remove"></i>删除</a>');
  78. return actions.join('');
  79. }
  80. }]
  81. };
  82. $.table.init(options);
  83. });
  84. function onClickRow(row, $element){
  85. alert("单击行userId:" + row.userId + " userName:" + row.userName);
  86. }
  87. function onDblClickRow(row, $element){
  88. alert("双击行userId:" + row.userId + " userName:" + row.userName);
  89. }
  90. function onClickCell(field, value, row, $element){
  91. alert("单击格name:" + field + " value:" + value);
  92. }
  93. function onDblClickCell(field, value, row, $element){
  94. alert("双击格name:" + field + " value:" + value);
  95. }
  96. function onCheck(row, $element){
  97. alert("选中行userId:" + row.userId + " userName:" + row.userName);
  98. }
  99. function onUncheck(row, $element){
  100. alert("取消行userId:" + row.userId + " userName:" + row.userName);
  101. }
  102. function onCheckAll(rowsAfter, rowsBefore){
  103. var rows = $.map(rowsAfter, function(row) {
  104. return $.common.getItemField(row, "userId");
  105. });
  106. alert("全选行:" + rows);
  107. }
  108. function onUncheckAll(rowsAfter, rowsBefore){
  109. var rows = $.map(rowsBefore, function(row) {
  110. return $.common.getItemField(row, "userId");
  111. });
  112. alert("取消行:" + rows);
  113. }
  114. function responseHandler(res){
  115. alert("请求获取数据后处理回调函数");
  116. }
  117. function onLoadSuccess(data){
  118. alert("当所有数据被加载时触发");
  119. }
  120. </script>
  121. </body>
  122. </html>