diff --git a/assets/controllers/elements/datatables/datatables_controller.js b/assets/controllers/elements/datatables/datatables_controller.js index 3f339302..c53db751 100644 --- a/assets/controllers/elements/datatables/datatables_controller.js +++ b/assets/controllers/elements/datatables/datatables_controller.js @@ -239,4 +239,16 @@ export default class extends Controller { return this.element.dataset.select ?? false; } + invertSelection() { + //Do nothing if the datatable is not selectable + if(!this.isSelectable()) { + return; + } + + //Invert the selected rows on the datatable + const selected_rows = this._dt.rows({selected: true}); + this._dt.rows().select(); + selected_rows.deselect(); + } + } diff --git a/templates/components/datatables.macro.html.twig b/templates/components/datatables.macro.html.twig index dadfad69..9c88e461 100644 --- a/templates/components/datatables.macro.html.twig +++ b/templates/components/datatables.macro.html.twig @@ -32,6 +32,8 @@ {# #}