Cell and Row Selection

Cell or Row Selection is generally an operation performed by AG Grid rather than AdapTable.

However there are a few features, events and other pieces of functionality concerning selection that are useful.

Exporting Cell Selection

A small, but popular, feature in AdapTable is the ability for the user to select a range of cells and then choose Export Selected Cells from the Context Menu.

This will run the Selected Cells System Report in the Export Module with a Destination of Excel.

tip

An alternative is to run the Selected Cells report from the Export Toolbar or Tool Panel which enables a different destination to be selected

Selection Changed Event

AdapTable fires the SelectionChangedEvent whenever the cell / row selection in the Grid changes.

This provides very detailed information of the current Grid selection.

SelectionChangedInfo

It has a single selectionChangedInfo object which includes full details of all Selected Cells and Rows (if the latter has been activated):

PropertyDescription
selectedCellInfoDetails of cells currently selected in the Grid
selectedRowInfoDetails of rows currently selected in the Grid

Selected Cells

The Selected Cell Info class contains 2 arrays

  • columns - This is an array of Adaptable Column

    tip

    This is helpful if you want to see if the Column is ReadOnly or a spcecial type of Column

  • gridCells - The Grid Cell class provides full information about the Selected Cell. Its properties are:

    PropertyDescription
    columnColumn in which cell is situtated
    displayValueDisplay value of cell (e.g. if formatted)
    normalisedValueNormalised value of cell
    primaryKeyValuePrimary Key column's value in row - how Adaptable locates the cell
    rawValueActual raw value of cell
    rowNodeAG Grid Row Node that holds the cell

Selected Rows

The Selected Row Info contains a collection of Grid Row objects.

This provides full information about the selected row including its underlying data:

PropertyDescription
primaryKeyValuePrimary Key column's value for Row - how Adaptable locates a cell
rowDataActual data in the Row
rowInfoObject which provides 'meta data' about the Row
rowNodeAG Grid Row Node object for the Row

The rowInfo property is itself an object - of type RowInfo.

It contains a number of useful boolean properties and is defined as follows:

PropertyDescription
isDisplayedIs Row displayed (ie. filtered, not necessarily in viewport)
isExpandedIs Row expanded (if a group row)
isGroupIs Row grouped
isMasterIs Row a Master Row (in a Master-Detail grid)
isSelectedIs Row selected
rowGroupLevelWhat level the Row is (if Row Grouping is active)

FAQ

Why am I unable to select a range of cells?

Make sure that you have the correct AG Module selected: either @ag-grid-enterprise/all-modules or @ag-grid-enterprise/range-selection.

Also ensure that you have the correct AG Grid Selection Options set.

Why is the Selection Changed event returning rows which are not visible in the grid?

This is by design. AG Grid and Adaptable both list all rows that are currently selected - irrespective of whether they pass the current filter or search.

You can use the rowInfo property to return just a collection of displayed (i.e. filtered) rows:

api.eventApi.on('SelectionChanged', (info: SelectionChangedInfo) => {
const gridRows: GridRow[] = info.selectedRowInfo.gridRows;
const selectedRows: GridRow[] = gridRows.filter((gr) => gr.rowInfo?.isDisplayed);
});

More Information