0

I have a grid which is based on jQuery DataTables Checkboxes. It pretty much looks like the basic example that gyrocode have on their webpage Does anyone know if I can have all checkboxes checked when the table first loads please (including the master checkbox, the one at the top that checks/unchecks all with a single click)

I tried $("input.dt-checkboxes").prop("checked", true); but that checks only the entries that are currently shown on the datatable's page

Gyrocode.com
  • 57,606
  • 14
  • 150
  • 185
Aenaon
  • 3,169
  • 4
  • 32
  • 60

1 Answers1

1

you can use cells.checkboxes.select(), filter the cells but, but we actually return true for all rows here, a working fiddle:

...
'initComplete': function(settings){
  var api = this.api();

  api.cells(
    api.rows(function(idx, data, node){
      return  true;
    }).indexes(),
    0
  ).checkboxes.select();
},
...
ROOT
  • 11,363
  • 5
  • 30
  • 45
  • 1
    Yes, correct. I actually got something similar. I used `createdCell': function(td){this.api().cell(td).checkboxes.select()}` with `deferRender': true`. I am not sure if there is a different but your answer is happily accepted. Many thanks for looking into this – Aenaon May 11 '20 at 15:31