1

How can I add checkbox with ability to 'check-all' and single check in first column of dataTable.. column which doesn't came from server-side script? So far I was able to put only at the end of table one button.

$(document).ready(function() {
  $('#example').DataTable( {
    "processing": true,
    "serverSide": true,
    "ajax": "response.php", 

    "aoColumnDefs": [
      {
        "aTargets": [7],
        "mData": null,
        "mRender": function (data, type, full) {
          return '<a class="btn btn-info btn-sm" href=edit.php?id=' + full[0] + '>' + 'Edit' + '</a>';
        }             
      }]
  });
});

and the html part

<table id="example" class="display table table-striped table-bordered responsive">
  <thead>
    <tr>
      <th>№</th>
      <th>Program</th>
      <th>Subject</th>
      <th>Number</th>
      <th>Description</th>                              
      <th>Keywords</th> 
      <th>Action</th>
    </tr>
  </thead>
</table>
Mosh Feu
  • 28,354
  • 16
  • 88
  • 135
  • Possible duplicate of [jquery check uncheck all checkboxes with a button](http://stackoverflow.com/questions/5229023/jquery-check-uncheck-all-checkboxes-with-a-button) – Chris Apr 14 '16 at 14:04
  • It is not duplicate. I'm using `dataTables`.. it is different –  Apr 14 '16 at 14:05
  • See this fiddle: https://jsfiddle.net/gyrocode/07Lrpqm7/ – Mosh Feu Apr 14 '16 at 14:11
  • @MoshFeu thank's but I have tried this. The problem with this is that I can't put both columns `one at front` and `one at the end`... So far I was succeed with only one custom column –  Apr 14 '16 at 14:15
  • Why not? https://jsfiddle.net/7e69e2ux/1/ – Mosh Feu Apr 14 '16 at 14:33
  • I want to preserve my last column which is on `js` on my question. But somehow they can't work together.. `eturn '' + 'Edit' + '';` –  Apr 14 '16 at 14:35
  • So first column `checkbox` last column `edit button` between them is the server-side data that is coming. –  Apr 14 '16 at 14:36

0 Answers0