{% set table=sa_crud['table'] %}
{% if hasattr(table, 'sacrud_list_col') %}
  {% set visible_columns=table.sacrud_list_col %}
{% else %}
  {% set visible_columns=sa_crud['col'] %}
{% endif %}

<div class="sa_table checkboxFilter">
  <!--create-->
  <a href="{{ request.route_url('sa_create', table=table.__tablename__) }}">
    Add a new {{ table.__tablename__ }}
  </a> | <a href="#" id="sa_union">Union of the fields</a>
  {% set isdnd = False %}
  {% if sa_crud['mapper_args']['order_by'] %}
    {% set isdnd = True %}
  {% endif %}
  <table id="sa_index">
    {% if sa_crud %}
      <thead>
        <tr>
          <td>
            <input type="checkbox">
          </td>
          {% for col in visible_columns %}
            <th>
              {{ col.info.verbose_name or col.name }}
            </th>
          {% endfor %}
          <th>actions</th>
        </tr>
      </thead>
      <tbody>
      {% for row in sa_crud['row'] %}
        {% set row_id = row[sa_crud['pk']] %}
        <tr valign="top" id="{{ sa_crud['table'].__tablename__ }}_{{ row_id }}">
          <td>
            <input type="checkbox" value="{{ row_id }}" id="sa_row_{{ row_id }}" class="sa_row_chk_box">
          </td>

          {% for col in visible_columns %}
            <td>
              {{ row.__getattribute__(col.name)|string|truncate(200) }}
            </td>
          {% endfor %}
          <td>
            {% include 'sacrud/forms/actions.jinja2' with context %}
          </td>
        </tr>
      {% endfor %}
    {% else %}
      <tr><td>There are no open objects</td></tr>
    {% endif %}
    </tbody>
  </table>
</div>
