SelectionConfig()

Usage

Source

SelectionConfig(**kwargs)

Description

Build a compact selection configuration dictionary that you can unpack into DataTable(...) or pass to table.update_selection(...).

Parameters

selectionTrigger: str

Description: Enables row selection and decides how it is triggered. Expected inputs: 'cell', 'checkbox'. Example: selectionTrigger="checkbox".

selectedRecordIds: list[Any]

Description: Controlled list of selected row ids. Example: selectedRecordIds=[1, 4, 8].

selectedRecords: list[dict]

Description: Controlled list of selected record payloads. Example: selectedRecords=[{"id": 1, "name": "Avery"}].

selectableRowRules: bool | dict | list

Description: Rule definition that marks which rows are selectable. Example: selectableRowRules=[{"selector": {"status": "Active"}, "value": True}].

disabledSelectionRowRules: bool | dict | list

Description: Rule definition that disables row selection for matching rows. Example: disabledSelectionRowRules=[{"selector": {"archived": True}, "value": True}].

selectionCheckboxRules: dict | list

Description: Conditional checkbox props for the selection column. Example: selectionCheckboxRules=[{"selector": {"locked": True}, "value": {"disabled": True}}].

selectionCheckboxProps: dict

Description: Shared props for each row-selection checkbox. Example: selectionCheckboxProps={"size": "sm"}.

allRecordsSelectionCheckboxProps: dict

Description: Props for the “select all” checkbox in the header. Example: allRecordsSelectionCheckboxProps={"aria-label": "Select all rows"}.

selectionColumnClassName: str

Description: CSS class applied to the selection column. Example: selectionColumnClassName="table-selection-col".

selectionColumnStyle: dict
Description: Inline style mapping applied to the selection column. Example: selectionColumnStyle={"width": 44}.

Returns

dict
A dictionary with None values removed.

Notes

This helper is a convenience for building clean config objects. It does not mutate a table and it drops keys whose value is None.

Examples

>>> SelectionConfig(selectionTrigger="checkbox", selectedRecordIds=[1, 2])
{'selectionTrigger': 'checkbox', 'selectedRecordIds': [1, 2]}