single_head_table.html 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. {% macro get_table(headers,rows,table_height,table_width,lock_column_count) %}
  2. <div style="overflow: auto;height: {{table_height}};width:{{table_width}};float: left;">
  3. <table class="table table-striped table-bordered table-hover" style="border:1px solid gray;">
  4. <thead>
  5. <tr>
  6. {% set _left = 0 %}
  7. {% for item in headers %}
  8. {% set name = item[0] %}
  9. {% set width = item[1] %}
  10. <th style="line-height: 30px;border: 1px solid #ddd;padding: unset;vertical-align: middle;text-align: center;
  11. {% if width %} width: {{width}}px;{% endif %}
  12. {% if lock_column_count and loop.index<=lock_column_count %}
  13. {% if loop.index>1 %}{% set _left = _left + headers[(loop.index-2)][1] %}{% endif %}
  14. left:{{_left}}px;z-index: 3;{% endif %}">{{name}}
  15. </th>
  16. {% endfor %}
  17. </tr>
  18. </thead>
  19. <tbody>
  20. {% for row in rows %}
  21. <tr>
  22. {% set _left = 0 %}
  23. {% for item in row %}
  24. <td
  25. {% if lock_column_count and loop.index<=lock_column_count %}
  26. {% if loop.index>1 %}{% set _left = _left + headers[(loop.index-2)][1] %}{% endif %}
  27. style="left:{{_left}}px;background-color:lightpink;z-index: 1;position: sticky;{{item[1]}}"
  28. {% endif %}
  29. {% if item[2] %} {{item[2]}} {% endif %}
  30. >{{item[0]}}
  31. </td>
  32. {% endfor %}
  33. </tr>
  34. {% endfor %}
  35. </tbody>
  36. </table>
  37. </div>
  38. {% endmacro %}