<!DOCTYPE html>
<html>
  <head>
    <script src="https://code.jquery.com/jquery-3.6.3.js"></script>
<link href="https://cdn.datatables.net/2.2.2/css/dataTables.dataTables.css" rel="stylesheet" integrity="sha384-ZVBvXH2IGOw6fHIntvmU2wOUGWutDViMwSQwdGEvaJkHVvm1S8N/HE/zBK91NXSV" crossorigin="anonymous">
<link href="https://cdn.datatables.net/buttons/3.2.2/css/buttons.dataTables.css" rel="stylesheet" integrity="sha384-WnU9UKIFykmC5nUngG4IGkdl3+/E5Rx7JmiggfjyAY804EuDkGcxL4aJMdN5iuTJ" crossorigin="anonymous">
<link href="https://cdn.datatables.net/select/3.0.0/css/select.dataTables.css" rel="stylesheet" integrity="sha384-BFcTahKzxalLFZINPV5uMsgsaxUMxCdXeTdkMal/2rM0rl+xZGVSniOXU8CxjSZ1" crossorigin="anonymous">
 
<script src="https://cdn.datatables.net/2.2.2/js/dataTables.js" integrity="sha384-gGekiWQ/bm8p71RTsvhPShoIBxcf8BsVjRTi0WY8FvxuQa2nKS0PKHiSXV9nfW/A" crossorigin="anonymous"></script>
<script src="https://cdn.datatables.net/buttons/3.2.2/js/dataTables.buttons.js" integrity="sha384-wCLG3FbyFPnMZM65D+pam9KW+2joK88dh4jfSMK0OuMQ2cBQHV0t55OqmQduaQ1S" crossorigin="anonymous"></script>
<script src="https://cdn.datatables.net/select/3.0.0/js/dataTables.select.js" integrity="sha384-hJjpz/IhFX8FAfkNB7zZrVouwlDrs/fzYxtAlUH5Ks1daudIQpG5hRjFp4xIphDb" crossorigin="anonymous"></script>
    <meta charset=utf-8 />
    <title>DataTables - JS Bin</title>
  </head>
  <body>
    <div class="container">
      <table id="example" class="display" width="100%">
        <thead>
            <tr>
                <th></th>
                <th>First name</th>
                <th>Last name</th>
                <th>Position</th>
                <th>Office</th>
            </tr>
        </thead>
        <tfoot>
            <tr>
                <th></th>
                <th>First name</th>
                <th>Last name</th>
                <th>Position</th>
                <th>Office</th>
            </tr>
        </tfoot>
      </table>
    </div>
  </body>
</html>
 
DataTable.Api.register( 'select.deselectAll()', function ( klass ) {
    return this.iterator( 'table', function ( ctx, index ) {
      var dt = new DataTable.Api(ctx);
      ctx._select_set = [];
      dt.draw('page');
    } );
} );
var table = new DataTable('#example', {
  processing: true,
  serverSide: true,
  ajax: {
    url: '/ssp/objects.php',
    type: 'post'
  },
    columns: [
        {data: null, orderable: false, searchable: false, render: DataTable.render.select()},
        {data: 'first_name'},
        {data: 'last_name'},
        {data: 'position'},
        {data: 'office'}
    ],
    order: [[1, 'asc']],
    select: true,
    layout: {
        topStart: {
            buttons: [
                'pageLength',
                {
                    text: 'Deselect All',
                    action: function (e, dt) {
                      
                      // Call the custom API
                      dt.select.deselectAll();
                      
                      console.log(dt.select.cumulative().rows)
                    }
                }
            ]
        }
    },
});
1 error
Line 36: Missing semicolon.
Output 300px

This bin was created anonymously and its free preview time has expired. Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers