GridSelection
Configs
1
Configs
1Selection 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
Properties
9Class hierarchy
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.
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
Functions
16Deselects all selected rows and cells. If store is filtered, this will unselect all visible rows only. Any selections made prior to filtering remains.
| Parameter | Type | Description |
|---|---|---|
removeCurrentRecordsOnly | Boolean | Pass |
silent | Boolean | Pass |
If in cell selection mode, this deselects one cell. If not, this deselects the cell's record.
| Parameter | Type | Description |
|---|---|---|
cellSelector | GridLocationConfig | GridLocation |
Normalized cell selector
If in cell selection mode, this deselects a number of cells. If not, this deselects corresponding records.
| Parameter | Type | Description |
|---|---|---|
cellSelectors | GridLocationConfig[] | GridLocation[] |
Normalized cell selectors
Deselect one row
| Parameter | Type | Description |
|---|---|---|
recordOrId | Model | String | Number | Record or an id for a record |
Deselect one or more rows
| Parameter | Type | Description |
|---|---|---|
recordOrIds | Model | String | Number | Model[] | String[] | Number[] | An array of records or ids for a record |
Checks whether a cell is selected.
| Parameter | Type | Description |
|---|---|---|
cellSelector | GridLocationConfig | GridLocation | Cell selector { id: x, column: xx } |
includeRow | Boolean | to also check if row is selected |
true if cell is selected, otherwise false
Checks whether a cell or row can be selected.
| Parameter | Type | Description |
|---|---|---|
recordCellOrId | Model | GridLocationConfig | GridLocation | String | Number | Record or cell or record id |
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.
| Parameter | Type | Description |
|---|---|---|
cellSelectorOrId | GridLocationConfig | GridLocation | String | Number | Model | Cell selector { id: x, column: xx } or row id, or record |
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.
| Parameter | Type | Description |
|---|---|---|
options | GridLocationConfig | GridLocation | Object | A cell selector ({ id: rowId, columnId: 'columnId' }) or a config object |
options.cell | GridLocationConfig | GridLocation | A cell selector ({ id: rowId, columnId: 'columnId' }) |
options.scrollIntoView | Boolean | BryntumScrollOptions | Specify |
options.addToSelection | Boolean | Specify |
options.silent | Boolean | Specify |
Cell selector
Selects a range of cells, from a cell selector (GridLocation) to another
| Parameter | Type | Description |
|---|---|---|
from | GridLocation | GridLocationConfig | |
to | GridLocation | GridLocationConfig |
If in cell selection mode, this selects a number of cells. If not, this selects corresponding records.
| Parameter | Type | Description |
|---|---|---|
options | Object | GridLocationConfig[] | GridLocation[] | An array of cell selectors ({ id: rowId, columnId: 'columnId' }) or a config object |
options.cells | GridLocationConfig[] | GridLocation[] | An array of cell selectors { id: rowId, columnId: 'columnId' } |
options.scrollIntoView | Boolean | BryntumScrollOptions | Specify |
options.addToSelection | Boolean | Specify |
options.silent | Boolean | Specify |
Cell selectors
Selects rows corresponding to a range of records (from fromId to toId)
| Parameter | Type | Description |
|---|---|---|
fromId | String | Number | |
toId | String | Number |
Select one row
| Parameter | Type | Description |
|---|---|---|
options | Object | Model | String | Number | A record or id to select or a config object describing the selection |
options.record | Model | String | Number | Record or record id, specifying null will deselect all |
options.column | Column | The column to scroll into view if |
options.scrollIntoView | Boolean | BryntumScrollOptions | Specify |
options.addToSelection | Boolean | Specify |
Select one or more rows
| Parameter | Type | Description |
|---|---|---|
options | Object | Model[] | String[] | Number[] | An array of records or ids for a record or a config object describing the selection |
options.records | Model[] | String[] | Number[] | An array of records or ids for a record |
options.column | Column | The column to scroll into view if |
options.scrollIntoView | Boolean | BryntumScrollOptions | Specify |
options.addToSelection | Boolean | Specify |
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.
| Parameter | Type | Description |
|---|---|---|
index | Number | Index at which to remove a block of records. Only valid if the second, |
toRemove | Model[] | Number | Either the number of records to remove starting at the passed |
toAdd | Model[] | Model | A record, or an array of records to add. |
Events
4
Events
4Fires 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 }) => {
});| Parameter | Type | Description |
|---|---|---|
action | String |
|
mode | row | cell |
|
source | Grid | |
deselected | Model[] | The records to be deselected in this operation. |
selected | Model[] | The records to be selected in this operation. |
selection | Model[] | The records in the current selection, before applying |
deselectedCells | GridLocation[] | The cells to be deselected in this operation. |
selectedCells | GridLocation[] | The cells to be selected in this operation. |
cellSelection | GridLocation[] | The cells in the current selection, before applying |
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 }) => {
});| Parameter | Type | Description |
|---|---|---|
source | Grid | |
selectedCells | GridLocationConfig[] | GridLocation[] | The cells that is currently being dragged over |
selectedRecords | Model[] | 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 }) => {
});| Parameter | Type | Description |
|---|---|---|
action | select | deselect |
|
mode | row | cell |
|
source | Grid | |
deselected | Model[] | The records deselected in this operation. |
selected | Model[] | The records selected in this operation. |
selection | Model[] | The records in the new selection. |
deselectedCells | GridLocation[] | The cells deselected in this operation. |
selectedCells | GridLocation[] | The cells selected in this operation. |
cellSelection | GridLocation[] | The cells in the new selection. |
The selectionMode configuration has been changed.
// Adding a listener using the "on" method
gridSelection.on('selectionModeChange', ({ selectionMode }) => {
});| Parameter | Type | Description |
|---|---|---|
selectionMode | Object | The new selectionMode |
Event handlers
4
Event handlers
4Called before the selection changes. Returning false from a listener prevents the change
new GridSelection({
onBeforeSelectionChange({ action, mode, source, deselected, selected, selection, deselectedCells, selectedCells, cellSelection }) {
}
});| Parameter | Type | Description |
|---|---|---|
action | String |
|
mode | row | cell |
|
source | Grid | |
deselected | Model[] | The records to be deselected in this operation. |
selected | Model[] | The records to be selected in this operation. |
selection | Model[] | The records in the current selection, before applying |
deselectedCells | GridLocation[] | The cells to be deselected in this operation. |
selectedCells | GridLocation[] | The cells to be selected in this operation. |
cellSelection | GridLocation[] | The cells in the current selection, before applying |
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 }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | Grid | |
selectedCells | GridLocationConfig[] | GridLocation[] | The cells that is currently being dragged over |
selectedRecords | Model[] | 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 }) {
}
});| Parameter | Type | Description |
|---|---|---|
action | select | deselect |
|
mode | row | cell |
|
source | Grid | |
deselected | Model[] | The records deselected in this operation. |
selected | Model[] | The records selected in this operation. |
selection | Model[] | The records in the new selection. |
deselectedCells | GridLocation[] | The cells deselected in this operation. |
selectedCells | GridLocation[] | The cells selected in this operation. |
cellSelection | GridLocation[] | The cells in the new selection. |
The selectionMode configuration has been changed.
new GridSelection({
onSelectionModeChange({ selectionMode }) {
}
});| Parameter | Type | Description |
|---|---|---|
selectionMode | Object | The new selectionMode |
Typedefs
1
Typedefs
1| Parameter | Type | Description |
|---|---|---|
cell | Boolean | Set to |
row | Boolean | Set to |
multiSelect | Boolean | Allow multiple selection with ctrl and |
alwaysMultiSelect | Boolean | Allow multiple selection by simply clicking a row/checkbox |
checkbox | Boolean | CheckColumnConfig | Set to |
checkboxIndex | Number | String | Positions the checkbox column at the provided index or to the
right of a provided column id. Defaults to |
checkboxOnly | Boolean | Select rows only when clicking in the checkbox column.
Requires cell selection config to be |
showCheckAll | Boolean | Set to |
showCheckAllInGroupRows | Boolean | Set to |
deselectFilteredOutRecords | Boolean | Set to |
includeChildren | Boolean | String | Set to |
includeParents | Boolean | all | some | Set to |
preserveSelectionOnPageChange | Boolean | In |
preserveSelectionOnDatasetChange | Boolean | In |
deselectOnClick | Boolean | Toggles whether the Grid should deselect a selected row or cell when clicking it |
dragSelect | Boolean | Set to |
selectOnKeyboardNavigation | Boolean | Set to |
column | Boolean | Set to |
rowNumber | Boolean | RowNumberColumnConfig | Set to |
selectRecordOnCell | Boolean | Set to |