refresh.html 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. <!-- data-auto-refresh设置true为启用自动刷新插件
  11. data-auto-refresh-interval为每次自动刷新发生的时间(以秒为单位)默认60。
  12. data-auto-refresh-silent设置为true可以自动无提示刷新。默认: true
  13. data-auto-refresh-status 设置true为启用自动刷新。这是表加载时自动刷新的状态。单击按钮切换此属性。这只是自动刷新的默认状态,因为用户始终可以通过单击按钮来更改它。 默认: true -->
  14. <table id="bootstrap-table" data-auto-refresh="true" data-auto-refresh-interval="30"></table>
  15. </div>
  16. </div>
  17. </div>
  18. <div th:include="include :: footer"></div>
  19. <th:block th:include="include :: bootstrap-table-auto-refresh-js" />
  20. <script th:inline="javascript">
  21. var prefix = ctx + "demo/table";
  22. $(function() {
  23. var options = {
  24. url: prefix + "/list",
  25. showSearch: false,
  26. showRefresh: false,
  27. showToggle: false,
  28. showColumns: false,
  29. columns: [{
  30. checkbox: true
  31. },
  32. {
  33. field : 'userId',
  34. title : '用户ID'
  35. },
  36. {
  37. field : 'userCode',
  38. title : '用户编号'
  39. },
  40. {
  41. field : 'userName',
  42. title : '用户姓名'
  43. },
  44. {
  45. field : 'userPhone',
  46. title : '用户手机'
  47. },
  48. {
  49. field : 'userEmail',
  50. title : '用户邮箱'
  51. },
  52. {
  53. field : 'userBalance',
  54. title : '用户余额'
  55. },
  56. {
  57. title: '操作',
  58. align: 'center',
  59. formatter: function(value, row, index) {
  60. var actions = [];
  61. actions.push('<a class="btn btn-danger btn-xs" href="javascript:;" onclick="remove(this)"><i class="fa fa-remove"></i>删除</a>');
  62. return actions.join('');
  63. }
  64. }]
  65. };
  66. $.table.init(options);
  67. });
  68. // 假删除操作
  69. function remove(obj) {
  70. $.modal.confirm("确认要删除吗?", function() {
  71. $(obj).parents("tr").remove();
  72. $.modal.msgSuccess('已删除!');
  73. });
  74. }
  75. </script>
  76. </body>
  77. </html>