API Docs for:
Show:

gallery-datatable-selection Module

Available since 3.6.0

A class extension for DataTable that adds "highlight" and "select" actions via mouse selection. The extension works in either "cell" mode or "row" mode (set via attribute selectionMode).

Highlighting is controlled by the highlightMode attribute (either "cell" or "row"). (Highlighting provides a "mouseover" indication only), and a delegated "mouseover" event is defined in this module.

Selection is provided via "click" listeners, by setting a delegated "click" handler on the TD or TR elements.

This extension includes the ability to select "multiple" items, by setting the selectionMulti attribute (enabled using browser multi-select click modifier, i.e. "Cmd" key on Mac OSX or "Ctrl" key on Windows / Linux).

Additionally, a "range" selection capability is provided by using the browser range selector click key modifier, specifically the Shift key on most systems.

The extension has been written to allow preserving the "selected" rows or cells during "sort" operations. This is accomplished by storing the selected TR's basis record, specifically the "clientId" attribute which remains unique after sorting operations.

Specific attributes are provided that can be read for current selections, including the ATTRS selectedRows, and selectedCells.

Typical usage would be to set the "selectionMode" and "highlightMode" attributes (and selectionMulti if desired) and then to provide a positive control (like a BUTTON or A link) to process the selections. Two events are provided, selection and selected but these fire for every "click" action, which may not be ideal -- especially for multi selections.

This module provides the following classes: