<!DOCTYPE html>
<html>
  <head>
    <script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
    <link href="https://nightly.datatables.net/css/jquery.dataTables.css" rel="stylesheet" type="text/css" />
    <script src="https://nightly.datatables.net/js/jquery.dataTables.js"></script>
<link href="https://nightly.datatables.net/select/css/select.dataTables.css?_=83ccd9fe32dc99a890e17a9f1bbde5a4.css" rel="stylesheet" type="text/css" />
<script src="https://nightly.datatables.net/select/js/dataTables.select.js?_=83ccd9fe32dc99a890e17a9f1bbde5a4"></script>
<link href="https://nightly.datatables.net/searchpanes/css/searchPanes.dataTables.css?_=5c6e38dbaaf467e0d790080ff9947c2c.css" rel="stylesheet" type="text/css" />
<script src="https://nightly.datatables.net/searchpanes/js/dataTables.searchPanes.js?_=5c6e38dbaaf467e0d790080ff9947c2c"></script>
    <meta charset=utf-8 />
    <title>DataTables - JS Bin</title>
  </head>
  <body>
    <div class="container">
      <table id="example" class="display nowrap" width="100%">
        <thead>
          <tr>
            <th>Name</th>
            <th>Position</th>
            <th>Office</th>
            <th>Age</th>
            <th>Start date</th>
            <th>Salary</th>
          </tr>
        </thead>
        <tfoot>
          <tr>
            <th>Name</th>
            <th>Position</th>
            <th>Office</th>
            <th>Age</th>
            <th>Start date</th>
            <th>Salary</th>
          </tr>
        </tfoot>
        <tbody>
          <tr>
            <td>Tiger Nixon</td>
            <td>System Architect</td>
            <td>Edinburgh</td>
            <td>61</td>
            <td>2011/04/25</td>
            <td>$3,120</td>
          </tr>
          <tr>
            <td>Garrett Winters</td>
            <td>Director</td>
            <td>Edinburgh</td>
            <td>63</td>
            <td>2011/07/25</td>
            <td>$5,300</td>
          </tr>
          <tr>
            <td>Ashton Cox</td>
            <td>Technical Author</td>
            <td>San Francisco</td>
            <td>66</td>
            <td>2009/01/12</td>
            <td>$4,800</td>
          </tr>
          <tr>
            <td>Cedric Kelly</td>
            <td>Director</td>
            <td>Edinburgh</td>
            <td>22</td>
            <td>2012/03/29</td>
            <td>$3,600</td>
          </tr>
          <tr>
            <td>Jenna Elliott</td>
            <td>Financial Controller</td>
            <td>Edinburgh</td>
            <td>33</td>
            <td>2008/11/28</td>
            <td>$5,300</td>
          </tr>
        </tbody>
      </table>
    </div>
  </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 table = $('#example').DataTable({
    dom: 'lfrtip',
    columnDefs: [{
      targets: [1],
      searchPanes: {
        show: true,
        dtOpts: {
          columnDefs: [{
            targets: [0],
            render: function(data, type, row, meta) {   
              var total = 0;
              var f = table.rows().data().filter(function(v,i) {
                if ( v[1] === data) {
                  total += parseInt(v[3]);
                }
              });
              let pill = '<span  class="dtsp-pill">' + total + '</span>';
               return '<div class="dtsp-nameCont"><span title="' + data + '" class="dtsp-name">' +
                            data + '</span>' +
                            pill + '</div>';              
              
            }
          }]
        }
      }
    }]
  });
  
  new $.fn.dataTable.SearchPanes(table, {});
  table.searchPanes.container().prependTo(table.table().container());
  table.searchPanes.resizePanes();
  
} );
Output 300px

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

Dismiss x
public
Bin info
anonymouspro
0viewers