<!DOCTYPE html>
<html>
  <head>
    <!-- jQuery 3.6.0 -->
    <script src="https://code.jquery.com/jquery-3.6.0.js"></script>
    <!-- Bootstrap4 -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.min.js" integrity="sha384-+sLIOodYLS7CIrQpBjl+C7nPvqq+FbNUBDunl/OZv93DB7Ln/533i8e/mZXLi/P+" crossorigin="anonymous"></script>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
    <!-- DataTables 1.12.1 -->
    <script src="https://cdn.datatables.net/1.12.1/js/jquery.dataTables.min.js"></script>
    <!-- DataTables Bootstrap4 1.12.1 -->
    <script src="https://cdn.datatables.net/1.12.1/js/dataTables.bootstrap4.min.js"></script>
    <link href="https://cdn.datatables.net/1.12.1/css/dataTables.bootstrap4.min.css" rel="stylesheet" type="text/css" />
    <!-- SearchPanes nightly! -->
    <script src="https://nightly.datatables.net/searchpanes/js/dataTables.searchPanes.js?123"></script>
    <!-- works fine with SearchPanes 2.0.2 -->
<!--
    <script src="https://cdn.datatables.net/searchpanes/2.0.2/js/dataTables.searchPanes.min.js"></script>
-->
    <!-- SearchPanes Bootstrap4 2.0.2 -->
    <script src="https://cdn.datatables.net/searchpanes/2.0.2/js/searchPanes.bootstrap4.min.js"></script>
    <link href="https://cdn.datatables.net/searchpanes/2.0.2/css/searchPanes.bootstrap4.min.css" rel="stylesheet" type="text/css" />
    <!-- Buttons 2.2.3 -->
    <script src="https://cdn.datatables.net/buttons/2.2.3/js/dataTables.buttons.min.js"></script>
    <!-- Buttons Bootstrap4 2.2.3 -->
    <script src="https://cdn.datatables.net/buttons/2.2.3/js/buttons.bootstrap4.min.js"></script>
    <link href="https://cdn.datatables.net/buttons/2.2.3/css/buttons.bootstrap4.min.css" rel="stylesheet" type="text/css" />
    <!-- Select 1.4.0 -->
    <script src="https://cdn.datatables.net/select/1.4.0/js/dataTables.select.min.js"></script>
    <!-- Select Bootstrap4 1.4.0 -->
    <link href="https://cdn.datatables.net/select/1.4.0/css/select.bootstrap4.min.css" rel="stylesheet" type="text/css" />
    <meta charset=utf-8 />
    <title>DataTables - JS Bin</title>
  </head>
  <body>
    <table id="debug" width="100%">
      <thead>
        <tr>
          <th>First Name</th>
          <th>Last Name</th>
          <th>Email</th>
        </tr>
      </thead>
    </table>
  </body>
</html>
 
body {
  font: 90%/1.45em "Helvetica Neue", HelveticaNeue, Verdana, Arial, Helvetica, sans-serif;
  margin: 0;
  padding: 0;
  color: #333;
  background-color: #fff;
}
 
$(document).ready(function () {
  var tableElement = jQuery('table#debug');
  tableElement.DataTable({
    dom: 'B<".searchPanes collapse mb-3 mt-3"><"d-flex flex-row justify-content-between align-items-start mb-3"<"flex-fill"i><"flex-fill"f>>t<"d-flex flex-row justify-content-between align-items-start mt-3"<"flex-fill"l><"flex-fill"p>>r',
    ajax: 'http://datatables.showroom.efficient.it/data/?simple',
    buttons: [
      {
        text: function (dt) {
          return dt.i18n('searchPanes.collapse', 'Filter', 0); 
        },
        action: function () {
          var DataTableApi = tableElement.dataTable().api();
          jQuery(DataTableApi.table().container())
            .children('div.searchPanes')
            .collapse('toggle');
        },
        init: function (dt, node) {
          tableElement.on('init.dt', function (event) {
            var SearchPanesContainer = jQuery(dt.table().container()).children(
              'div.searchPanes'
            );
            SearchPanesContainer.append(
              jQuery('<div class="card card-body pt-5">').append(
                jQuery(
                  '<button class="close position-absolute" style="right:10px;top:5px;"><span>&times;</span></button>'
                ).on('click', function (event) {
                  SearchPanesContainer.collapse('hide');
                  event.preventDefault();
                })
              )
            );
            new jQuery.fn.dataTable.SearchPanes(dt, {
              layout: 'columns-4',
              initCollapsed: true,
              cascadePanes: true,
              viewTotal: true,
              filterChanged: function (count) {
                node.text(
                  dt.i18n('searchPanes.collapse', 'Filter', count)
                );
              },
            });
            dt.searchPanes
              .container()
              .appendTo(SearchPanesContainer.find('div.card'));
            dt.searchPanes.resizePanes();
          });
        },
      },
    ],
    columns: [
      {
        data: 'first_name',
        name: 'first_name',
        searchPanes: {
          show: true,
        },
      },
      {
        data: 'last_name',
        name: 'last_name',
        searchPanes: {
          show: true,
        },
      },
      {
        data: 'email',
        name: 'email',
        searchPanes: {
          show: true,
        },
      },
    ],
    language: {
      searchPanes: {
        collapse: {
          0: 'Filter (%d)',
          _: 'Filter (%d)',
        },
      },
    },
  });
});
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers