<!DOCTYPE html>
<html>
  <head>
    <script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/jszip-2.5.0/dt-1.11.4/b-2.2.2/b-colvis-2.2.2/b-html5-2.2.2/b-print-2.2.2/datatables.min.css"/>
 
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/pdfmake.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/vfs_fonts.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/v/dt/jszip-2.5.0/dt-1.11.4/b-2.2.2/b-colvis-2.2.2/b-html5-2.2.2/b-print-2.2.2/datatables.min.js"></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>ICON STATUS</th>
            <th>Position</th>
            <th>data</th>
          </tr>
        </thead>
        <tfoot>
          <tr>
            <th>ICON STATUS</th>
            <th>Position</th>
            <th>data</th>
          </tr>
        </tfoot>
        <tbody>
          <tr>
            <td><img src="https://img.icons8.com/emoji/48/000000/green-circle-emoji.png"/> GREEN</td>
            <td>System Architect</td>
          </tr>
           <tr>
            <td><img src="https://img.icons8.com/emoji/48/000000/green-circle-emoji.png"/> GREEN</td>
            <td>System Architect</td>
               <td>10/4/2022</td>
          </tr>
           <tr>
            <td><img src="https://img.icons8.com/emoji/48/000000/red-apple.png"/> APPLE</td>
            <td>System Architect</td>
               <td>10/4/2022</td>
          </tr>
           <tr>
            <td><img src="https://img.icons8.com/emoji/48/000000/red-apple.png"/> APPLE</td>
            <td>System Architect</td>
               <td>10/8/2022</td>
          </tr>
           <tr>
            <td><img src="https://img.icons8.com/emoji/48/000000/banana-emoji.png"/> BANANA</td>
            <td>System Architect</td>
               <td>10/8/2022</td>
          </tr>
           <tr>
            <td><img src="https://img.icons8.com/emoji/48/000000/green-circle-emoji.png"/> GREEN</td>
            <td>System Architect</td>
               <td>10/9/2022</td>
          </tr>
          <tr>
            <td>Garrett Winters</td>
            <td>Director</td>
               <td>10/10/2022</td>
          </tr>
          <tr>
            <td>Ashton Cox</td>
            <td>Technical Author</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 groupColumn = 0;
var table = $('#example').DataTable({
  "dom": '<"top"i>rt<"bottom"flp><"clear">'
      paging: true,
      responsive: true,
      stateSave: true,
    columnDefs: [
            {
        orderable: false,
        targets: 2,
            render: function (data, type, row) {
          if ( type === 'filter' ) {
            // Strip HTML from the cell data and return only the text
            return data.replace(/<[^>]*>?/gm, '');
          }
          return data;
        }
            }
        ],
    buttons: [
        { extend: 'csv', text: 'CSV' },
        { extend: 'excel', text: 'EXCEL' },
        { extend: 'pdf', text: 'PDF' },
        { extend: 'print', text: 'STAMPA' }
    ],
    
      initComplete: function () {
      // Get the loaded states
      var states = this.api().state.loaded();
      // use column-selecotr to choose the columns
      this.api().columns( [2] ).every( function () {
        var column = this;
        var select = $('<select><option value="">All</option></select>')
        .appendTo( $(column.header()).empty() )
        .on( 'change', function () {
          var val = $.fn.dataTable.util.escapeRegex(
            $(this).val()
          );
          column
          .search( val ? '^'+val+'$' : '', true, false )
          .draw();
        } );
        // strip the HTML from the cell data to match the 
        column.data().unique().sort().each( function ( d, j ) {
          select.append( '<option value="'+d.replace(/<[^>]*>?/gm, '')+'">'+d+'</option>' )
        } );
        // Get column index and search term from stateSave
        var colIndex = column.index();
        var searchTerm = states.columns[colIndex].search.search;
        // Remove regex anchors ^ and $
        searchTerm = searchTerm.replace(/^\^/gm ,'')
        searchTerm = searchTerm.replace(/\$$/gm ,'')
        
        // Select the optioni matching the search term
        $( 'select', column.header() ).val(searchTerm);
      } );
    },
    "drawCallback": function ( settings ) {
            var api = this.api();
            var rows = api.rows( {page:'current'} ).nodes();
            var last=null;
 
            api.column(groupColumn, {page:'current'} ).data().each( function ( group, i ) {
                if ( last !== group ) {
                    $(rows).eq( i ).before(
                        '<tr class="group" style="background-color: #e7e7e7 !important"><td colspan="2">'+group+'</td></tr>'
                    );
 
                    last = group;
                }
            } )
            
        },
}).buttons().container().appendTo('#example_wrapper .col-md-6:eq(0)');
    
});
Output 300px

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

Dismiss x
public
Bin info
anonymouspro
0viewers