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

1 Answer 1

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();
},
...
Sign up to request clarification or add additional context in comments.

1 Comment

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.