thead.html 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <title>复杂表头 - 数据表格</title>
  2. <div class="layui-card layadmin-header">
  3. <div class="layui-breadcrumb" lay-filter="breadcrumb">
  4. <a lay-href="">主页</a>
  5. <a><cite>组件</cite></a>
  6. <a><cite>数据表格</cite></a>
  7. <a><cite>复杂表头</cite></a>
  8. </div>
  9. </div>
  10. <div class="layui-fluid">
  11. <div class="layui-row layui-col-space15">
  12. <div class="layui-col-md12">
  13. <div class="layui-card">
  14. <div class="layui-card-header">复杂表头</div>
  15. <div class="layui-card-body">
  16. <fieldset class="layui-elem-field layui-field-title">
  17. <legend>常用两级表头</legend>
  18. </fieldset>
  19. <table class="layui-table" lay-data="{width:800, page: true, limit: 6, limits:[6]}" lay-filter="test-table-thead1">
  20. <thead>
  21. <tr>
  22. <th lay-data="{checkbox:true, fixed:'left'}" rowspan="2"></th>
  23. <th lay-data="{field:'username', width:150}" rowspan="2">联系人</th>
  24. <th lay-data="{align:'center'}" colspan="3">地址</th>
  25. <th lay-data="{field:'amount', width:120}" rowspan="2">金额</th>
  26. <th lay-data="{fixed: 'right', width: 160, align: 'center', toolbar: '#test-table-thead-barDemo'}" rowspan="2">操作</th>
  27. </tr>
  28. <tr>
  29. <th lay-data="{field:'province', width:120}">省</th>
  30. <th lay-data="{field:'city', width:120}">市</th>
  31. <th lay-data="{field:'zone', width:200}">区</th>
  32. </tr>
  33. </thead>
  34. </table>
  35. <br>
  36. <fieldset class="layui-elem-field layui-field-title">
  37. <legend>更多级表头(可以无限极)</legend>
  38. </fieldset>
  39. <table class="layui-table" lay-data="{cellMinWidth: 80, page: true}" lay-filter="test-table-thead1">
  40. <thead>
  41. <tr>
  42. <th lay-data="{field:'username', width:80}" rowspan="3">联系人</th>
  43. <th lay-data="{field:'amount', width:120}" rowspan="3">金额</th>
  44. <th lay-data="{align:'center'}" colspan="5">地址1</th>
  45. <th lay-data="{align:'center'}" colspan="2">地址2</th>
  46. <th lay-data="{fixed: 'right', width: 160, align: 'center', toolbar: '#test-table-thead-barDemo'}" rowspan="3">操作</th>
  47. </tr>
  48. <tr>
  49. <th lay-data="{field:'province'}" rowspan="2">省</th>
  50. <th lay-data="{field:'city'}" rowspan="2">市</th>
  51. <th lay-data="{align:'center'}" colspan="3">详细</th>
  52. <th lay-data="{field:'province'}" rowspan="2">省</th>
  53. <th lay-data="{field:'city'}" rowspan="2">市</th>
  54. </tr>
  55. <tr>
  56. <th lay-data="{field:'street'}" rowspan="2">街道</th>
  57. <th lay-data="{field:'address'}">小区</th>
  58. <th lay-data="{field:'house'}">单元</th>
  59. </tr>
  60. </thead>
  61. </table>
  62. <script type="text/html" id="test-table-thead-barDemo">
  63. <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">按钮1</a>
  64. <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">按钮2</a>
  65. </script>
  66. <br>
  67. <blockquote class="layui-elem-quote">注:上述例子读取的均是静态模拟数据</blockquote>
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. <script>
  74. layui.use(['admin', 'table'], function(){
  75. var table = layui.table;
  76. table.init('test-table-thead1', {
  77. url: './json/table/demo2.js'
  78. });
  79. table.init('test-table-thead2', {
  80. url: './json/table/demo2.js'
  81. });
  82. });
  83. </script>