@serenity-is/corelib / GridRowSelectionMixin
Class: GridRowSelectionMixin
Defined in: src/ui/helpers/gridrowselectionmixin.tsx:47
A mixin that adds multi (checkbox) row selection behavior to a data grid, including a select-all header checkbox.
Constructors
Constructor
new GridRowSelectionMixin(
grid,options?):GridRowSelectionMixin
Defined in: src/ui/helpers/gridrowselectionmixin.tsx:109
Creates a new GridRowSelectionMixin for the given grid.
Parameters
grid
The data grid to attach the mixin to.
options?
Optional mixin options.
Returns
GridRowSelectionMixin
Properties
onSelectionChanged
onSelectionChanged:
PubSub<GridRowSelectionState>
Defined in: src/ui/helpers/gridrowselectionmixin.tsx:102
Notified with the state of the checked rows, after every change of them, e.g. to enable or disable the actions of a bar that acts on them. A mixin that replaces another one for the same grid keeps the subscribers of it, as the rows are the same ones, so a widget that was given the one before it goes on being told about them.
[typeInfo]
static[typeInfo]:ClassTypeInfo<"Serenity.">
Defined in: src/ui/helpers/gridrowselectionmixin.tsx:49
checkedRowClass
readonlystaticcheckedRowClass:"checked-row"="checked-row"
Defined in: src/ui/helpers/gridrowselectionmixin.tsx:88
The css class of the rows that are checked, which is not the one the selection models of the grid add to the cells of a selection range, so the two can be styled apart.
Accessors
selectColumnId
Get Signature
get
staticselectColumnId():string
Defined in: src/ui/helpers/gridrowselectionmixin.tsx:52
The id of the column that shows the checkboxes of the rows, which the mixin creates.
Returns
string
Methods
clear()
clear():
void
Defined in: src/ui/helpers/gridrowselectionmixin.tsx:423
Clears the checked rows, and repaints the rows, so that the check boxes and the rows that are told apart by checkedRowClass are shown unchecked right away.
Returns
void
destroy()
destroy():
void
Defined in: src/ui/helpers/gridrowselectionmixin.tsx:166
Detaches the mixin from the grid and cleans up event subscriptions.
Returns
void
getSelectedAsInt32()
getSelectedAsInt32():
number[]
Defined in: src/ui/helpers/gridrowselectionmixin.tsx:470
Returns the selected keys parsed as 32-bit integers.
Returns
number[]
The selected keys as int32 values.
getSelectedAsInt64()
getSelectedAsInt64():
number[]
Defined in: src/ui/helpers/gridrowselectionmixin.tsx:480
Returns the selected keys parsed as 64-bit integers.
Returns
number[]
The selected keys as int64 values.
getSelectedKeys()
getSelectedKeys():
string[]
Defined in: src/ui/helpers/gridrowselectionmixin.tsx:462
Returns the keys of the currently selected items.
Returns
string[]
The selected keys.
getSelectionState()
getSelectionState():
GridRowSelectionState
Defined in: src/ui/helpers/gridrowselectionmixin.tsx:373
Returns the state of the checked rows, including the ones the page the grid shows does not have.
Returns
resetCheckedAndRefresh()
resetCheckedAndRefresh():
void
Defined in: src/ui/helpers/gridrowselectionmixin.tsx:436
Clears the checked rows, and refreshes the grid view, e.g. after the rows are changed, so that the groups and the filters of the view are applied again, as well as the check boxes of the rows.
Returns
void
selectKeys()
selectKeys(
keys):void
Defined in: src/ui/helpers/gridrowselectionmixin.tsx:450
Selects the items with the given keys, keeping any existing selection.
Parameters
keys
string[]
The keys of the items to select.
Returns
void
setSelectedKeys()
setSelectedKeys(
keys):void
Defined in: src/ui/helpers/gridrowselectionmixin.tsx:490
Replaces the current selection with the items having the given keys.
Parameters
keys
string[]
The keys of the items to select.
Returns
void
updateSelectAll()
updateSelectAll():
void
Defined in: src/ui/helpers/gridrowselectionmixin.tsx:401
Updates the checked state of the select-all header button based on the current selection, and tells the subscribers of its change.
Returns
void
createSelectColumn()
Call Signature
staticcreateSelectColumn(columnOptions?):Column
Defined in: src/ui/helpers/gridrowselectionmixin.tsx:531
Creates a checkbox select column for the grid, including a select-all header.
Parameters
columnOptions?
Partial<Column>
Optional column options to merge into the select column, when the first argument is the function that returns the mixin.
Returns
Column
The select column definition.
Call Signature
staticcreateSelectColumn(getMixin?,columnOptions?):Column
Defined in: src/ui/helpers/gridrowselectionmixin.tsx:532
Creates a checkbox select column for the grid, including a select-all header.
Parameters
getMixin?
() => GridRowSelectionMixin
columnOptions?
Partial<Column>
Optional column options to merge into the select column, when the first argument is the function that returns the mixin.
Returns
Column
The select column definition.
formatSelectItem()
staticformatSelectItem(ctx):FormatterResult
Defined in: src/ui/helpers/gridrowselectionmixin.tsx:62
Formats a cell of the column of the checkboxes that select the rows, and is also what tells that column apart from the others, see isSelectColumn. It is a static method, instead of a closure of createSelectColumn, so that the same function is the format of every such column, and the column can be found whatever its id is.
Parameters
ctx
FormatterContext
The formatter context.
Returns
FormatterResult
The check box of the row, or an empty string for a row that has none.
isSelectColumn()
staticisSelectColumn(column):boolean
Defined in: src/ui/helpers/gridrowselectionmixin.tsx:515
Whether a column is the column of the checkboxes that select the rows of this mixin, which is a
utility column of the grid and not a data column, e.g. for the column picker or an export that leaves
it out. The column is told apart by its format function, which formatSelectItem sets, rather
than by its id, as a columns class can declare it with a RowSelectionColumn attribute of the server.
A column of the radio buttons of GridRadioSelectionMixin has an id of its own, so it is not
taken for this one.
Parameters
column
Column
The column to check.
Returns
boolean
tryGetInstance()
statictryGetInstance(grid):GridRowSelectionMixin
Defined in: src/ui/helpers/gridrowselectionmixin.tsx:158
Returns the mixin attached to a grid, if it has one, e.g. for the column that shows the checkboxes, or for a widget that acts on the checked rows.
Parameters
grid
The data grid, or the sleek grid of it.
ISleekGrid<any> | IDataGrid
Returns
GridRowSelectionMixin
The mixin, or null when the grid has none.