Checkboxes on a few columns Select All/None

Checkboxes on a few columns Select All/None

rosario.martonerosario.martone Posts: 3Questions: 0Answers: 0

I am trying to set up a grid where some of the columns are having a checkbox in the header column so I can trigger a function for select/deselect all the rows for that column. From what I can see, it looks like datatable.js doesn't offer the feature straight from the box?

Thanks for any help provided!

Replies

  • kthorngrenkthorngren Posts: 22,498Questions: 26Answers: 5,170

    The Select Checkbox examples show a select/deselect checkbox in the header. Does this help?

    Kevin

  • rosario.martonerosario.martone Posts: 3Questions: 0Answers: 0
    edited 11:40AM

    Hi Kevin, the selection should be available on each column and not only at the beginning of the table.
    Basically what I am trying to achieve is for example column 4, 5, 6 are having some checkboxes in the rows (for that column) so I would like to select/unselect all the values in the specific column, rather then selecting the entire row?
    The checkbox should come after the column name in the header and let me select/unselect all column values

  • rosario.martonerosario.martone Posts: 3Questions: 0Answers: 0

    Something like this basically. If I click on the chebox in the header, I will select all checkboxes in that specific column rows

  • allanallan Posts: 65,884Questions: 1Answers: 10,960 Site admin

    The API is the way to go here. Use column().nodes() to get the elements from the column, which you can then filter down to just the checkboxes, and toggle them.

    Here is a little example.

    I've used the .toDom() method from DataTables to access it's DOM library. If you prefer doing it without that library, column().nodes() returns an array-like object of the nodes so you can use them directly.

    You may wish to disable ordering on these columns, or perhaps use ColumnControl to provide ordering control buttons (rather than the whole header ordering on click).

    Allan

Sign In or Register to comment.