headerStyle.html 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. <table id="bootstrap-table"></table>
  11. </div>
  12. </div>
  13. </div>
  14. <div th:include="include :: footer"></div>
  15. <script th:inline="javascript">
  16. var prefix = ctx + "demo/table";
  17. var datas = [[${@dict.getType('sys_normal_disable')}]];
  18. $(function() {
  19. var options = {
  20. url: prefix + "/list",
  21. showSearch: false,
  22. showRefresh: false,
  23. showToggle: false,
  24. showColumns: false,
  25. headerStyle: headerStyle,
  26. columns: [{
  27. checkbox: true
  28. },
  29. {
  30. field : 'userId',
  31. title : '用户ID'
  32. },
  33. {
  34. field : 'userCode',
  35. title : '用户编号'
  36. },
  37. {
  38. field : 'userName',
  39. title : '用户姓名'
  40. },
  41. {
  42. field : 'userPhone',
  43. title : '用户手机'
  44. },
  45. {
  46. field : 'userEmail',
  47. title : '用户邮箱'
  48. },
  49. {
  50. field : 'userBalance',
  51. title : '用户余额'
  52. },
  53. {
  54. field: 'status',
  55. title: '用户状态',
  56. align: 'center',
  57. formatter: function(value, row, index) {
  58. return $.table.selectDictLabel(datas, value);
  59. }
  60. },
  61. {
  62. title: '操作',
  63. align: 'center',
  64. formatter: function(value, row, index) {
  65. var actions = [];
  66. actions.push('<a class="btn btn-success btn-xs" href="#"><i class="fa fa-edit"></i>编辑</a> ');
  67. actions.push('<a class="btn btn-danger btn-xs" href="#"><i class="fa fa-remove"></i>删除</a>');
  68. return actions.join('');
  69. }
  70. }]
  71. };
  72. $.table.init(options);
  73. });
  74. function headerStyle(column) {
  75. return {
  76. userId: {
  77. classes: 'uppercase'
  78. },
  79. userName: {
  80. css: { background: 'yellow' }
  81. },
  82. userBalance: {
  83. css: { color: 'red' }
  84. }
  85. } [column.field]
  86. }
  87. </script>
  88. </body>
  89. </html>