1

I am rendering a JQuery DataTable within a ReactJS application and the table draws fine. However when I try to draw checkboxes they are not drawn. I also tried to hard code two rows to be selected and I get a

TypeError: table.columns(...).select is not a function.

import 'datatables.net';
import dt from 'datatables.net-bs';
import 'datatables.net-select';

const table = container.find('.dataTable').DataTable({
  columnDefs: [{
    orderable: false,
    className: 'select-checkbox',
    targets: 0,
  }],
  select: {
    style: 'os',
    selector: 'td:first-child',
  },
  order: [[1, 'asc']],
});

table.columns([1, 2]).select();

Once I get row selection with checkboxes my next goal is to have column selection by checkboxes (ie row of checkboxes above header, on selection the column below is highlighted).

Any idea why checkbox row rendering may not be working?

1 Answer 1

1

Most likely you forgot to include CSS/JS files for Select extension. It needs to be included in addition to jQuery DataTables files.

Either use Download builder and include Select extension or download individual files for Select extension.

Also take a look at jQuery DataTables Checkboxes extension that simplifies handling of checkboxes in a table powered by jQuery DataTables.

Sign up to request clarification or add additional context in comments.

Comments

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.