child.html 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. <!-- 点击事件的方式打开使用 detailViewIcon: false and detailViewByClick: true
  11. data-detail-view-icon="false"
  12. data-detail-view-by-click="true" -->
  13. <table id="bootstrap-table"></table>
  14. </div>
  15. </div>
  16. </div>
  17. <div th:include="include :: footer"></div>
  18. <script th:inline="javascript">
  19. var prefix = ctx + "demo/table";
  20. var datas = [[${@dict.getType('sys_normal_disable')}]];
  21. $(function() {
  22. var options = {
  23. url: prefix + "/list",
  24. showSearch: false,
  25. showRefresh: false,
  26. showToggle: false,
  27. showColumns: false,
  28. detailView: true,
  29. onExpandRow : function(index, row, $detail) {
  30. initChildTable(index, row, $detail);
  31. },
  32. columns: [{
  33. checkbox: true
  34. },
  35. {
  36. field : 'userId',
  37. title : '用户ID'
  38. },
  39. {
  40. field : 'userCode',
  41. title : '用户编号'
  42. },
  43. {
  44. field : 'userName',
  45. title : '用户姓名'
  46. },
  47. {
  48. field : 'userPhone',
  49. title : '用户手机'
  50. },
  51. {
  52. field : 'userEmail',
  53. title : '用户邮箱'
  54. },
  55. {
  56. field : 'userBalance',
  57. title : '用户余额'
  58. },
  59. {
  60. field: 'status',
  61. title: '用户状态',
  62. align: 'center',
  63. formatter: function(value, row, index) {
  64. return $.table.selectDictLabel(datas, value);
  65. }
  66. },
  67. {
  68. title: '操作',
  69. align: 'center',
  70. formatter: function(value, row, index) {
  71. var actions = [];
  72. actions.push('<a class="btn btn-success btn-xs" href="javascript:;"><i class="fa fa-edit"></i>编辑</a> ');
  73. actions.push('<a class="btn btn-danger btn-xs" href="javascript:;"><i class="fa fa-remove"></i>删除</a>');
  74. return actions.join('');
  75. }
  76. }]
  77. };
  78. $.table.init(options);
  79. });
  80. initChildTable = function(index, row, $detail) {
  81. var childTable = $detail.html('<table style="table-layout:fixed"></table>').find('table');
  82. $(childTable).bootstrapTable({
  83. url: prefix + "/list",
  84. method: 'post',
  85. sidePagination: "server",
  86. contentType: "application/x-www-form-urlencoded",
  87. queryParams : {
  88. userName: '测试8'
  89. },
  90. columns: [{
  91. field : 'userId',
  92. title : '子表ID'
  93. },
  94. {
  95. field : 'userCode',
  96. title : '子表编号'
  97. },
  98. {
  99. field : 'userName',
  100. title : '子表姓名'
  101. },
  102. {
  103. field: 'status',
  104. title: '子表状态',
  105. align: 'center',
  106. formatter: function(value, row, index) {
  107. return $.table.selectDictLabel(datas, value);
  108. }
  109. }]
  110. });
  111. };
  112. </script>
  113. </body>
  114. </html>