table.html 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. {% load django_tables2 %}
  2. <table{% if table.attrs %} {{ table.attrs.as_html }}{% endif %}>
  3. {% if table.show_header %}
  4. <thead>
  5. <tr>
  6. {% for column in table.columns %}
  7. {% if column.orderable %}
  8. <th {{ column.attrs.th.as_html }}><a href="{% querystring table.prefixed_order_by_field=column.order_by_alias.next %}">{{ column.header }}</a></th>
  9. {% else %}
  10. <th {{ column.attrs.th.as_html }}>{{ column.header }}</th>
  11. {% endif %}
  12. {% endfor %}
  13. </tr>
  14. </thead>
  15. {% endif %}
  16. <tbody>
  17. {% for row in table.page.object_list|default:table.rows %}
  18. <tr {{ row.attrs.as_html }}>
  19. {% for column, cell in row.items %}
  20. <td {{ column.attrs.td.as_html }}>{{ cell }}</td>
  21. {% endfor %}
  22. </tr>
  23. {% empty %}
  24. {% if table.empty_text %}
  25. <tr>
  26. <td colspan="{{ table.columns|length }}" class="text-center text-muted">&mdash; {{ table.empty_text }} &mdash;</td>
  27. </tr>
  28. {% endif %}
  29. {% endfor %}
  30. </tbody>
  31. {% if table.has_footer %}
  32. <tfoot>
  33. <tr>
  34. {% for column in table.columns %}
  35. <td>{{ column.footer }}</td>
  36. {% endfor %}
  37. </tr>
  38. </tfoot>
  39. {% endif %}
  40. </table>