API Docs for:
Show:

Selection Module

Available since 3.6.0

A DataTable class extension that adds capability to provide a "checkbox" (INPUT[type=checkbox]) selection capability via a new column, which includes "select all" checkbox in the TH. The class uses only a few defined attributes to add the capability.

This extension works with sorted data and with paginated DataTable (via Y.DataTable.Paginator), by retaining a set of "primary keys" for the selected records.

Users define the "primary keys" by either setting a property flag of "primaryKey:true" in the DataTable column configuration OR by setting the primaryKeys attribute.

To enable the "checkbox" selection, set the attribute checkboxSelectMode to true, which will add a new column as the first column and sets listeners for checkbox selections.

To retrieve the "checkbox" selected records, the attribute checkboxSelected can be queried to return an array of objects of selected records (See method _getCheckboxSelected) for details.

Usage

    var dtable = new Y.DataTable({
        columns:    ['port','pname', 'ptitle'],
        data:       ports,
        scrollable: 'y',
        height:     '250px',

    // define two primary keys and enable checkbox selection mode ...
        primaryKeys:        [ 'port', 'pname' ],
        checkboxSelectMode: true

    }).render("#dtable");

This module provides the following classes: