* Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ // Load Dolibarr environment require '../../../../main.inc.php'; /** * @var DoliDB $db * @var HookManager $hookmanager * @var Translate $langs * @var User $user */ // Protection if external user if ($user->socid > 0) { accessforbidden(); } // Includes require_once DOL_DOCUMENT_ROOT . '/admin/tools/ui/class/documentation.class.php'; // Load documentation translations $langs->load('uxdocumentation'); // $documentation = new Documentation($db); $group = 'Content'; $experimentName = 'TableRowIntuitiveSelect'; $js = [ '/includes/ace/src/ace.js', '/includes/ace/src/ext-statusbar.js', '/includes/ace/src/ext-language_tools.js', ]; $css = [ ]; // Output html head + body - Param is Title $documentation->docHeader($langs->trans($experimentName, $group), $js, $css); // Set view for menu and breadcrumb $documentation->view = [$group, $experimentName]; // Output sidebar $documentation->showSidebar(); $form = new Form($db); ?>
showBreadCrumb(); ?>

trans($experimentName); ?>

showSummary(); ?>

Select table lines by Ctrl + Click

Description

This feature allows users to select or deselect table rows (<tr>) in an HTML table:

  • Holding down Ctrl (or Cmd on Mac) allows users to add or remove individual rows from the selection.
  • Holding down Shift allows users to select a range of rows between the last selected row and the clicked row.

Detailed Behavior

User Action Expected Result
Ctrl + Click on a row Toggles selection of the clicked row (add/remove).
Shift + Click on a row Selects all rows between the last selected and clicked row.

HTML Requirements

The table should follow a standard structure with <thead> and <tbody> elements, and each <tr> must be selectable by applying .row-with-select CSS class and have checkbox with .checkforselect class

Key Notes

  • The script supports Cmd key (for Mac users) as an alternative to Ctrl.
  • When Shift-clicking without a previously selected row, selection will not start.
  • When user start selection, the css rules will remove text selection possibility.
  • When the user double-clicks, the selection functionality is reactivated, but the reference to the last selected row is cleared, thus disabling the Shift + Click range selection behavior.
First Name Last Name Age Country
John Doe 37 U.S.A
Jack Sparrow 29 Caribbean
Sacha Ketchum 16 Kanto
Albert Einstein 72 Germany
John Doe 37 U.S.A
Jack Sparrow 29 Caribbean
Sacha Ketchum 16 Kanto
Albert Einstein 72 Germany
John Doe 37 U.S.A
Jack Sparrow 29 Caribbean
Sacha Ketchum 16 Kanto
Albert Einstein 72 Germany
John Doe 37 U.S.A
Jack Sparrow 29 Caribbean
Sacha Ketchum 16 Kanto
Albert Einstein 72 Germany
docFooter(); ?>