{% load django_tables2 django_tableaux %}
{% if table.show_header and not table.mobile %}
  {#  sort attributes and filter row #}
  <thead {{ table.attrs.thead.as_html }} style="margin: 0px;">
  <tr>
    {% for column in table.columns %}
      {% if column.name in table.columns_visible %}
        <th {{ column.attrs.th.as_html }}
            {% if table.mobile %}
              {% if column.name != "selection" and column.name in table.columns_fixed %}colspan="2" {% endif %}
            {% endif %}
            {% if column.orderable %}
              hx-target="#table_container" hx-push-url="true"
              hx-get="{% querystring table.prefixed_order_by_field=column.order_by_alias.next %}"
              name="sort"
              title="Click to sort by {{ column.name|capfirst }}"
            {% endif %}>
          {% if column.name == "selection" %}
            <input type="checkbox" id="select_all_page" name="select_all_page">
          {% else %}

            {% if column.orderable %}
              {% if column.is_ordered %}
                {% if "-" in column.order_by.0 %}{{ column.header }}&nbsp;&#9661;{% else %}{{ column.header }}&nbsp;&#9651;{% endif %}
              {% else %}
                {{ column.header }}<span style="color: lightgrey;">&nbsp;&#x25c7;</span>
              {% endif %}
            {% else %}
              &nbsp;&nbsp;{{ column.header }}
            {% endif %}
          {% endif %}
        </th>
      {% endif %}
    {% endfor %}
  </tr>
  {% if table.filter.style == table.filter.style.HEADER %}
    <tr>
      {% for field in table.header_fields %}
        <th>
          {% if field %}
            {% include templates.tb_filter_field with field=field header=True %}
          {% endif %}
        </th>
      {% endfor %}
    </tr>
  {% endif %}
  </thead>
{% endif %}
