reorderColumns.html 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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="btn-group-sm" id="toolbar" role="group">
  9. <a class="btn btn-success" onclick="orderColumns()">
  10. <i class="fa fa-refresh"></i> 恢复顺序
  11. </a>
  12. </div>
  13. <div class="row">
  14. <div class="col-sm-12 select-table table-bordered">
  15. <p class="select-title">按住表格列拖拽</p>
  16. <table id="bootstrap-table"
  17. data-reorderable-columns="true"></table>
  18. </div>
  19. </div>
  20. </div>
  21. <div th:include="include :: footer"></div>
  22. <script th:src="@{/js/jquery-ui-1.10.4.min.js}"></script>
  23. <th:block th:include="include :: bootstrap-table-reorder-columns-js" />
  24. <script th:inline="javascript">
  25. var prefix = ctx + "demo/table";
  26. var datas = [[${@dict.getType('sys_normal_disable')}]];
  27. $(function() {
  28. var options = {
  29. url: prefix + "/list",
  30. showSearch: false,
  31. showRefresh: false,
  32. showToggle: false,
  33. showColumns: false,
  34. columns: [{
  35. field : 'userId',
  36. title : '用户ID'
  37. },
  38. {
  39. field : 'userCode',
  40. title : '用户编号'
  41. },
  42. {
  43. field : 'userName',
  44. title : '用户姓名'
  45. },
  46. {
  47. field : 'userPhone',
  48. title : '用户手机'
  49. },
  50. {
  51. field : 'userEmail',
  52. title : '用户邮箱'
  53. },
  54. {
  55. field : 'userBalance',
  56. title : '用户余额'
  57. },
  58. {
  59. field: 'status',
  60. title: '用户状态',
  61. align: 'center',
  62. formatter: function(value, row, index) {
  63. return $.table.selectDictLabel(datas, value);
  64. }
  65. }]
  66. };
  67. $.table.init(options);
  68. });
  69. function orderColumns() {
  70. $('#bootstrap-table').bootstrapTable('orderColumns', {
  71. userId: 0,
  72. userCode: 1,
  73. userName: 2,
  74. userPhone: 3,
  75. userEmail: 4,
  76. userBalance: 5,
  77. status: 6
  78. })
  79. }
  80. </script>
  81. </body>
  82. </html>