GridSelection

Configs

1

Selection configuration settings, change these properties to control how selection works and what can be selected.

When configuring (creating an instance), set this to an object containing only those properties you want to change.

new Grid({
    selectionMode : {
       // Enables cell selection
       cell       : true,
       // Enabled cell and record selection by dragging
       dragSelect : true,
       // Enables selection of a column's cells by clicking the column header
       column     : true,
       // Shows a row number column which, when clicked, selected the row/record
       rowNumber  : true
    }
});

After the configuring is done, these properties will be monitored for changes, making it possible to alter the selection configuration at any time.

// Adds a selection checkbox column and makes that the only way to select
grid.selectionMode.checkboxOnly = true;

// Deactivates the auto selection of rows and cells when keyboard navigating
grid.selectionMode.selectOnKeyboardNavigation = false;

Properties

9

Class hierarchy

isGridSelection: Boolean= truereadonly
Identifies an object as an instance of GridSelection class, or subclass thereof.
isGridSelection: Boolean= truereadonlystatic
Identifies an object as an instance of GridSelection class, or subclass thereof.

Selection

In cell selection mode, this will get the cell selector for the (last) selected cell. Set to an available cell selector to select only that cell. Or use selectCell() instead.

selectedCellCSSSelector: Stringreadonly

CSS selector for the currently selected cell. Format is "[data-index=index] [data-column-id=column]".

In cell selection mode, this will get the cell selectors for all selected cells. Set to an array of available cell selectors. Or use selectCells() instead.

The last selected record. Set to select a row or use Grid#selectRow. Set to null to deselect all

Selected records.

If deselectFilteredOutRecords is false (default) this will include selected records which has been filtered out.

If preserveSelectionOnPageChange is true (defaults to false) this will include selected records on all pages.

If selectRecordOnCell is true (default) this will include any record which has at least one cell selected.

Can be set as array of ids:

grid.selectedRecords = [1, 2, 4, 6]

Selected records. Records selected via cell selection is excluded.

If deselectFilteredOutRecords is false (default) this will include selected records which has been filtered out.

If preserveSelectionOnPageChange is true (defaults to false) this will include selected records on all pages.

if selectRecordOnCell is false this will return same records as selectedRecords.

Can be set as array of ids:

grid.selectedRecords = [1, 2, 4, 6]

Selection configuration settings, change these properties to control how selection works and what can be selected.

When configuring (creating an instance), set this to an object containing only those properties you want to change.

new Grid({
    selectionMode : {
       // Enables cell selection
       cell       : true,
       // Enabled cell and record selection by dragging
       dragSelect : true,
       // Enables selection of a column's cells by clicking the column header
       column     : true,
       // Shows a row number column which, when clicked, selected the row/record
       rowNumber  : true
    }
});

After the configuring is done, these properties will be monitored for changes, making it possible to alter the selection configuration at any time.

// Adds a selection checkbox column and makes that the only way to select
grid.selectionMode.checkboxOnly = true;

// Deactivates the auto selection of rows and cells when keyboard navigating
grid.selectionMode.selectOnKeyboardNavigation = false;

Functions

16

Deselects all selected rows and cells. If store is filtered, this will unselect all visible rows only. Any selections made prior to filtering remains.

ParameterTypeDescription
removeCurrentRecordsOnlyBoolean

Pass false to clear all selected records, and true to only clear selected records in the current set of records

silentBoolean

Pass true not to fire any event upon selection change

If in cell selection mode, this deselects one cell. If not, this deselects the cell's record.

ParameterTypeDescription
cellSelectorGridLocationConfig | GridLocation
Returns: GridLocation -

Normalized cell selector

If in cell selection mode, this deselects a number of cells. If not, this deselects corresponding records.

ParameterTypeDescription
cellSelectorsGridLocationConfig[] | GridLocation[]
Returns: GridLocation[] -

Normalized cell selectors

Deselect one row

ParameterTypeDescription
recordOrIdModel | String | Number

Record or an id for a record

Deselect one or more rows

ParameterTypeDescription
recordOrIdsModel | String | Number | Model[] | String[] | Number[]

An array of records or ids for a record

Checks whether a cell is selected.

ParameterTypeDescription
cellSelectorGridLocationConfig | GridLocation

Cell selector { id: x, column: xx }

includeRowBoolean

to also check if row is selected

Returns: Boolean -

true if cell is selected, otherwise false

Checks whether a cell or row can be selected.

ParameterTypeDescription
recordCellOrIdModel | GridLocationConfig | GridLocation | String | Number

Record or cell or record id

Returns: Boolean -

true if cell or row can be selected, otherwise false

Checks whether a row is selected. Will not check if any of a row's cells are selected.

ParameterTypeDescription
cellSelectorOrIdGridLocationConfig | GridLocation | String | Number | Model

Cell selector { id: x, column: xx } or row id, or record

Returns: Boolean -

true if row is selected, otherwise false

This selects all rows. If store is filtered, this will merge the selection of all visible rows with any selection made prior to filtering.

If in cell selection mode, this selects one cell. If not, this selects the cell's record.

ParameterTypeDescription
optionsGridLocationConfig | GridLocation | Object

A cell selector ({ id: rowId, columnId: 'columnId' }) or a config object

options.cellGridLocationConfig | GridLocation

A cell selector ({ id: rowId, columnId: 'columnId' })

options.scrollIntoViewBoolean | BryntumScrollOptions

Specify false to prevent row from being scrolled into view

options.addToSelectionBoolean

Specify true to add to selection, defaults to false which replaces

options.silentBoolean

Specify true to not trigger any events when selecting the cell

Returns: GridLocation -

Cell selector

Selects a range of cells, from a cell selector (GridLocation) to another

ParameterTypeDescription
fromGridLocation | GridLocationConfig
toGridLocation | GridLocationConfig

If in cell selection mode, this selects a number of cells. If not, this selects corresponding records.

ParameterTypeDescription
optionsObject | GridLocationConfig[] | GridLocation[]

An array of cell selectors ({ id: rowId, columnId: 'columnId' }) or a config object

options.cellsGridLocationConfig[] | GridLocation[]

An array of cell selectors { id: rowId, columnId: 'columnId' }

options.scrollIntoViewBoolean | BryntumScrollOptions

Specify false to prevent row from being scrolled into view

options.addToSelectionBoolean

Specify true to add to selection, defaults to false which replaces

options.silentBoolean

Specify true to not trigger any events when selecting the cell

Returns: GridLocation[] -

Cell selectors

Selects rows corresponding to a range of records (from fromId to toId)

ParameterTypeDescription
fromIdString | Number
toIdString | Number

Select one row

ParameterTypeDescription
optionsObject | Model | String | Number

A record or id to select or a config object describing the selection

options.recordModel | String | Number

Record or record id, specifying null will deselect all

options.columnColumn

The column to scroll into view if scrollIntoView is not specified as false. Defaults to the grid's first column.

options.scrollIntoViewBoolean | BryntumScrollOptions

Specify false to prevent row from being scrolled into view

options.addToSelectionBoolean

Specify true to add to selection, defaults to false which replaces

Select one or more rows

ParameterTypeDescription
optionsObject | Model[] | String[] | Number[]

An array of records or ids for a record or a config object describing the selection

options.recordsModel[] | String[] | Number[]

An array of records or ids for a record

options.columnColumn

The column to scroll into view if scrollIntoView is not specified as false. Defaults to the grid's first column.

options.scrollIntoViewBoolean | BryntumScrollOptions

Specify false to prevent row from being scrolled into view

options.addToSelectionBoolean

Specify true to add to selection, defaults to false which replaces

Removes and adds records to/from the selection at the same time. Analogous to the Array splice method.

Note that if records that are specified for removal are also in the toAdd array, then those records are not removed and then appended. They remain in the same position relative to all remaining records.

ParameterTypeDescription
indexNumber

Index at which to remove a block of records. Only valid if the second, toRemove argument is a number.

toRemoveModel[] | Number

Either the number of records to remove starting at the passed index, or an array of records to remove (If an array is passed, the index is ignored).

toAddModel[] | Model

A record, or an array of records to add.

Events

4

Fires before the selection changes. Returning false from a listener prevents the change

// Adding a listener using the "on" method
gridSelection.on('beforeSelectionChange', ({ action, mode, source, deselected, selected, selection, deselectedCells, selectedCells, cellSelection }) => {

});
ParameterTypeDescription
actionString

'select'/'deselect'

moderow | cell

'row'/'cell'

sourceGrid
deselectedModel[]

The records to be deselected in this operation.

selectedModel[]

The records to be selected in this operation.

selectionModel[]

The records in the current selection, before applying selected and deselected

deselectedCellsGridLocation[]

The cells to be deselected in this operation.

selectedCellsGridLocation[]

The cells to be selected in this operation.

cellSelectionGridLocation[]

The cells in the current selection, before applying selectedCells and deselectedCells

Fires while drag selecting. UI will update with current range, but the cells will not be selected until mouse up. This event can be listened for to perform actions while drag selecting.

// Adding a listener using the "on" method
gridSelection.on('dragSelecting', ({ source, selectedCells, selectedRecords }) => {

});
ParameterTypeDescription
sourceGrid
selectedCellsGridLocationConfig[] | GridLocation[]

The cells that is currently being dragged over

selectedRecordsModel[]

The records that is currently being dragged over

The selection has been changed.

// Adding a listener using the "on" method
gridSelection.on('selectionChange', ({ action, mode, source, deselected, selected, selection, deselectedCells, selectedCells, cellSelection }) => {

});
ParameterTypeDescription
actionselect | deselect

'select'/'deselect'

moderow | cell

'row'/'cell'

sourceGrid
deselectedModel[]

The records deselected in this operation.

selectedModel[]

The records selected in this operation.

selectionModel[]

The records in the new selection.

deselectedCellsGridLocation[]

The cells deselected in this operation.

selectedCellsGridLocation[]

The cells selected in this operation.

cellSelectionGridLocation[]

The cells in the new selection.

The selectionMode configuration has been changed.

// Adding a listener using the "on" method
gridSelection.on('selectionModeChange', ({ selectionMode }) => {

});
ParameterTypeDescription
selectionModeObject

The new selectionMode

Event handlers

4

Called before the selection changes. Returning false from a listener prevents the change

new GridSelection({
    onBeforeSelectionChange({ action, mode, source, deselected, selected, selection, deselectedCells, selectedCells, cellSelection }) {

    }
});
ParameterTypeDescription
actionString

'select'/'deselect'

moderow | cell

'row'/'cell'

sourceGrid
deselectedModel[]

The records to be deselected in this operation.

selectedModel[]

The records to be selected in this operation.

selectionModel[]

The records in the current selection, before applying selected and deselected

deselectedCellsGridLocation[]

The cells to be deselected in this operation.

selectedCellsGridLocation[]

The cells to be selected in this operation.

cellSelectionGridLocation[]

The cells in the current selection, before applying selectedCells and deselectedCells

Called while drag selecting. UI will update with current range, but the cells will not be selected until mouse up. This event can be listened for to perform actions while drag selecting.

new GridSelection({
    onDragSelecting({ source, selectedCells, selectedRecords }) {

    }
});
ParameterTypeDescription
sourceGrid
selectedCellsGridLocationConfig[] | GridLocation[]

The cells that is currently being dragged over

selectedRecordsModel[]

The records that is currently being dragged over

The selection has been changed.

new GridSelection({
    onSelectionChange({ action, mode, source, deselected, selected, selection, deselectedCells, selectedCells, cellSelection }) {

    }
});
ParameterTypeDescription
actionselect | deselect

'select'/'deselect'

moderow | cell

'row'/'cell'

sourceGrid
deselectedModel[]

The records deselected in this operation.

selectedModel[]

The records selected in this operation.

selectionModel[]

The records in the new selection.

deselectedCellsGridLocation[]

The cells deselected in this operation.

selectedCellsGridLocation[]

The cells selected in this operation.

cellSelectionGridLocation[]

The cells in the new selection.

The selectionMode configuration has been changed.

new GridSelection({
    onSelectionModeChange({ selectionMode }) {

    }
});
ParameterTypeDescription
selectionModeObject

The new selectionMode

Typedefs

1
ParameterTypeDescription
cellBoolean

Set to true to enable cell selection. This takes precedence over row selection, but rows can still be selected programmatically or with checkbox or RowNumber selection. Required for column selection

rowBoolean

Set to true to enable row selection. This takes precedence over row selection. Required for row selection

multiSelectBoolean

Allow multiple selection with ctrl and [Shift + Click] or with checkbox selection. Required for dragSelect and column selection

alwaysMultiSelectBoolean

Allow multiple selection by simply clicking a row/checkbox

checkboxBoolean | CheckColumnConfig

Set to true to add a checkbox selection column to the grid, or pass a config object for the CheckColumn. Note that the checkbox selection column should not be configured with a field, since it is linked to grid selection and not to record data

checkboxIndexNumber | String

Positions the checkbox column at the provided index or to the right of a provided column id. Defaults to 0 or to the right of an included RowNumberColumn

checkboxOnlyBoolean

Select rows only when clicking in the checkbox column. Requires cell selection config to be false and checkbox to be set to true. This setting was previously named rowCheckboxSelection

showCheckAllBoolean

Set to true to add a checkbox to the selection column header to select/deselect all rows. Requires checkbox to also be set to true. Not supported when Store is configured with lazyLoad

showCheckAllInGroupRowsBoolean

Set to true to add a checkbox to group rows to be able to check/uncheck all group members

deselectFilteredOutRecordsBoolean

Set to true to deselect records when they are filtered out

includeChildrenBoolean | String

Set to true to also select/deselect child nodes when a parent node is selected by toggling the checkbox. Set to 'always' to always select/deselect child nodes.

includeParentsBoolean | all | some

Set to all or true to auto select parent if all its children gets selected. If one gets deselected, the parent will also be deselected. Set to 'some' to select parent if one of its children gets selected. The parent will be deselected if all children gets deselected.

preserveSelectionOnPageChangeBoolean

In row selection mode, this flag controls whether the Grid should preserve its selection when loading a new page of a paged data store. Defaults to false.

preserveSelectionOnDatasetChangeBoolean

In row selection mode, this flag controls whether the Grid should preserve its selection of cells / rows when loading a new dataset (assuming the selected records are included in the newly loaded dataset)

deselectOnClickBoolean

Toggles whether the Grid should deselect a selected row or cell when clicking it

dragSelectBoolean

Set to true to enable multiple selection by dragging. Requires to also be set to true. Also requires the RowReorder feature to be set to gripOnly

selectOnKeyboardNavigationBoolean

Set to false to disable auto-selection by keyboard navigation. This will activate the select keyboard shortcut

columnBoolean

Set to true to be able to select whole columns of cells by clicking the header. Requires cell to be set to true. Not supported when Store is configured with lazyLoad

rowNumberBoolean | RowNumberColumnConfig

Set to true, or a config object to add a RowNumberColumn which, when clicked, selects the row

selectRecordOnCellBoolean

Set to false not to include the record in the selectedRecords array when one of the record row's cells is selected