child.html 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. detailView: true,
  26. onExpandRow : function(index, row, $detail) {
  27. initChildTable(index, row, $detail);
  28. },
  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. field: 'status',
  58. title: '用户状态',
  59. align: 'center',
  60. formatter: function(value, row, index) {
  61. return $.table.selectDictLabel(datas, value);
  62. }
  63. },
  64. {
  65. title: '操作',
  66. align: 'center',
  67. formatter: function(value, row, index) {
  68. var actions = [];
  69. actions.push('<a class="btn btn-success btn-xs" href="#"><i class="fa fa-edit"></i>编辑</a> ');
  70. actions.push('<a class="btn btn-danger btn-xs" href="#"><i class="fa fa-remove"></i>删除</a>');
  71. return actions.join('');
  72. }
  73. }]
  74. };
  75. $.table.init(options);
  76. });
  77. initChildTable = function(index, row, $detail) {
  78. var childTable = $detail.html('<table style="table-layout:fixed"></table>').find('table');
  79. $(childTable).bootstrapTable({
  80. url: prefix + "/list",
  81. method: 'post',
  82. sidePagination: "server",
  83. contentType: "application/x-www-form-urlencoded",
  84. queryParams : {
  85. userName: '测试8'
  86. },
  87. columns: [{
  88. field : 'userId',
  89. title : '子表ID'
  90. },
  91. {
  92. field : 'userCode',
  93. title : '子表编号'
  94. },
  95. {
  96. field : 'userName',
  97. title : '子表姓名'
  98. },
  99. {
  100. field: 'status',
  101. title: '子表状态',
  102. align: 'center',
  103. formatter: function(value, row, index) {
  104. return $.table.selectDictLabel(datas, value);
  105. }
  106. }]
  107. });
  108. };
  109. </script>
  110. </body>
  111. </html>