<div class="table-responsive">
    <div class="d-flex justify-content-between mb-3 align-items-center">
      <div class="fw-bold fs-3">
        <span class="me-2">{{ _('Items') }} : {{ data.results | length }}</span>
      </div>
      <button class="btn btn-dark" onclick="copyTableJsonToClipboard('selftools-db-query-results-rows')">
        Copy as JSON
      </button>
    </div>
    <table id="selftools-db-query-results-rows" class="table table-striped table-bordered table-hover">
        <thead class="table-light">
          <tr>
            {% for field in data.fields %}
              <th scope="col">{{ field }}</th>
            {% endfor %}
          </tr>
        </thead>
        <tbody>
          {% for row in data.results %}
            <tr>
                {% for val in row %}
                    <td>{{ val }}</td>
                {% endfor %}
            </tr>
          {% endfor %}
        </tbody>
    </table>
</div>

<script>
    var dataTable =  new DataTable('#selftools-db-query-results-rows', {
        layout: {
          topStart: {
              pageLength: {
                  menu: [ 10, 25, 50, 100, 1000, 10000 ]
              },
              buttons: [
                'csv'
              ],  
          },
          topEnd: {
            searchBuilder: {},
              search: {
                  placeholder: 'Search here'
              }
          },
        }
    });
</script>
