<!DOCTYPE html>
<html>
  <head>
    <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
    
 <link href="https://cdn.datatables.net/2.0.3/css/dataTables.dataTables.css" rel="stylesheet" type="text/css" />
<script src="https://cdn.datatables.net/2.0.3/js/dataTables.js"></script>   
 <link href="https://cdn.datatables.net/responsive/3.0.0/css/responsive.dataTables.css" rel="stylesheet" type="text/css" />
<script src="https://cdn.datatables.net/responsive/3.0.0/js/dataTables.responsive.js"></script>
<link href="https://cdn.datatables.net/rowgroup/1.5.0/css/rowGroup.dataTables.css" rel="stylesheet" type="text/css" />
<script src="https://cdn.datatables.net/rowgroup/1.5.0/js/dataTables.rowGroup.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></th>
            <th>Name</th>
            <th>Position</th>
            <th>Office</th>
            <th>Age</th>
            <th>Start date</th>
            <th>Salary</th>
            <th>Age</th>
            <th>Age</th>
            <th>Age</th>
            <th>Age</th>
            <th>Age</th>
            <th>Age</th>
            <th>Age</th>
            <th>Age</th>
            <th>Age</th>
            <th class="never">Age hidden</th>
          </tr>
        </thead>
        <tfoot>
          <tr>
            <th></th>
            <th>Name</th>
            <th>Position</th>
            <th>Office</th>
            <th>Age</th>
            <th>Start date</th>
            <th>Salary</th>
            <th>Age</th>
            <th>Age</th>
            <th>Age</th>
            <th>Age</th>
            <th>Age</th>
            <th>Age</th>
            <th>Age</th>
            <th>Age</th>
            <th>Age</th>
            <th class="never">Age hidden</th>
          </tr>
        </tfoot>
        <tbody>
          <tr>
            <td></td>
            <td>Tiger Nixon</td>
            <td>System Architect</td>
            <td>Edinburgh</td>
            <td>61</td>
            <td>2011/04/25</td>
            <td>$3,120</td>
            <td>61</td>
            <td>61</td>
            <td>61</td>
            <td>61</td>
            <td>61</td>
            <td>61</td>
            <td>61</td>
            <td>61</td>
            <td>61</td>
            <td>61</td>
          </tr>
          <tr>
            <td></td>
            <td>Garrett Winters</td>
            <td>Director</td>
            <td>Edinburgh</td>
            <td>63</td>
            <td>2011/07/25</td>
            <td>$5,300</td>
            <td>63</td>
            <td>63</td>
            <td>63</td>
            <td>63</td>
            <td>63</td>
            <td>63</td>
            <td>63</td>
            <td>63</td>
            <td>63</td>
            <td>63</td>
          </tr>
          <tr>
            <td></td>
            <td>Ashton Cox</td>
            <td>Technical Author</td>
            <td>San Francisco</td>
            <td>66</td>
            <td>2009/01/12</td>
            <td>$4,800</td>
            <td>66</td>
            <td>66</td>
            <td>66</td>
            <td>66</td>
            <td>66</td>
            <td>66</td>
            <td>66</td>
            <td>66</td>
            <td>66</td>
            <td>66</td>
          </tr>
           <tr>
            <td></td>
            <td>Ashton Simpsons</td>
            <td>Author</td>
            <td>San Francisco</td>
            <td>66</td>
            <td>2015/01/12</td>
            <td>$4,800</td>
            <td>66</td>
            <td>66</td>
            <td>66</td>
            <td>66</td>
            <td>66</td>
            <td>66</td>
            <td>66</td>
            <td>66</td>
            <td>66</td>
            <td>66</td>
          </tr>
          <tr>
            <td></td>
            <td>Cedric Kelly</td>
            <td>Javascript Developer</td>
            <td>Edinburgh</td>
            <td>22</td>
            <td>2012/03/29</td>
            <td>$3,600</td>
            <td>22</td>
            <td>22</td>
            <td>22</td>
            <td>22</td>
            <td>22</td>
            <td>22</td>
            <td>22</td>
            <td>22</td>
            <td>22</td>
            <td>22</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;
}
 
var table = new DataTable('#example', {
  columnDefs: [
    { className: 'dtr-control', targets: [0] },
    { orderable: false, targets: [0] },
],
  //orderFixed: [16, 'desc'],  // not working
    order: [[16, 'desc']], // order is on col #1 and #6
  responsive: {
    details: {
                type: 'column',
                target: 'tr',
                renderer: function (api, rowIdx, columns) {
                    var data = $.map(columns, function (col, i) {
                        return col.hidden
                            ? '<p class="has-text-grey px-2 py-2"><span class="has-text-weight-semibold smallcaps">'+ col.title + ' : </span>' + col.data + '</p>'
                            : '';
                        }).join('');
                    return data ;
                }
            }
        },
   rowGroup: {
        dataSrc: 16,
          endRender: function (rows, group) {
            var resposniveVisiblity = $('#example').DataTable().columns().responsiveHidden().toArray();
            var numVisible = resposniveVisiblity.filter(x => x === true).length;
            return $('<tr/>')
              .append('<td>Visible columns ' + numVisible + '</td>');
            
            
          }
    }
});
table.on('responsive-resize', function () {
  table.draw('page');
});
2 warnings
Line 15: Bad line breaking before '?'.
Line 26: 'arrow function syntax (=>)' is available in ES6 (use esnext option) or Mozilla JS extensions (use moz).
Output 300px

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

Dismiss x
public
Bin info
anonymouspro
0viewers