<!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" />
    <!-- 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" />
    <!-- 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" />
    <!-- SearchPanes -->
    <!-- with 2.0.2: filter is applied after reload, but filter item is not selected; button text is not set -->
    <script src="https://cdn.datatables.net/searchpanes/2.0.2/js/dataTables.searchPanes.js"></script>
    <!-- with nightly: filter is not applied after reload; button text is not set-->
<!--
    <script src="https://nightly.datatables.net/searchpanes/js/dataTables.searchPanes.js?2022-09-16"></script>
-->
    <!-- SearchPanes Bootstrap4 -->
    <script src="https://cdn.datatables.net/searchpanes/2.0.2/js/searchPanes.bootstrap4.js"></script>
<!--
    <script src="https://nightly.datatables.net/searchpanes/js/searchPanes.bootstrap4.js?2022-09-16"></script>
-->
    <link href="https://nightly.datatables.net/searchpanes/css/searchPanes.bootstrap4.css?2022-09-1" rel="stylesheet" type="text/css" />
    
    <title>DataTables - JS Bin</title>
    <meta charset=utf-8 />
  </head>
  <body>
    <table id="example_2" width="100%">
      <thead>
        <tr>
          <th>First name</th>
          <th>Last name</th>
          <th>Email</th>
          <th>Gender</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 outerTableElement = $('table#example_2');
  outerTableElement.DataTable({
    dom: 'Bft',
    ajax: 'http://datatables.showroom.efficient.it/data/?outer',
    buttons: [
      {
        extend: 'searchPanes',
        config: {
          layout: 'columns-1',
          initCollapsed: true,
          cascadePanes: true,
          viewTotal: true
        }
      }
    ],
    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
        }
      },
      {
        data: 'gender',
        name: 'gender',
        searchPanes: {
          show: true
        }
      }
    ],
    stateSave: true,
    serverSide: true,
    stateSaveCallback: function(settings, data) {
      jQuery.ajax({
        type: 'POST',
        url: 'http://datatables.showroom.efficient.it/state/save_new.php',
        dataType: 'json',
        contentType: 'application/json',
        data: JSON.stringify({
          id: 'example_2',
          data: data
        })
      });
    },
    stateLoadCallback: function(settings, callback) {
      jQuery.ajax({
        type: 'POST',
        url: 'http://datatables.showroom.efficient.it/state/load.php',
        dataType: 'json',
        data: {
          id: 'example_2'
        },
        success: function(response) {
          if(response.success) {
            callback(response.data);
          }
          else {
            callback(null);
          }
        }
      });
    }
  });
});
Output 300px

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

Dismiss x
public
Bin info
anonymouspro
0viewers