ColumnGroup()

Usage

Source

ColumnGroup(
    group_id=None,
    /,
    *,
    columns=None,
    groups=None,
    **kwargs,
)

Description

Build a grouped-header definition for DataTable(groups=[...]). Use this when you want multiple header rows, such as a “Compensation” group above salary and bonus columns.

Parameters

group_id: str | None = None

Description: Stable identifier for the group. This is the id you use later with table.group_columns(selector="compensation", ...). Example: group_id="compensation".

columns: list[Any] | None = None

Description: Column references attached directly to this group. Each item may be an accessor string like "salary" or a full column dictionary. Example: columns=["salary", "bonus"].

groups: list[dict[str, Any]] | None = None

Description: Nested child groups for multi-row grouped headers. Example: groups=[ColumnGroup("cash", columns=["salary", "bonus"])].

title: str

Description: Visible header label for the group. Example: title="Compensation".

style: dict

Description: Inline style mapping applied to the group header cell. Example: style={"textAlign": "center"}.

headerStyle: dict

Description: Header-specific style mapping forwarded to the frontend. Example: headerStyle={"backgroundColor": "var(--mantine-color-gray-0)"}.

textAlign: str
Description: Alignment hint for grouped-header content. Expected inputs: values accepted by Mantine/DataTable such as 'left', 'center', 'right'. Example: textAlign="center".

Returns

dict
A grouped-header configuration dictionary.

Notes

Group dictionaries are plain Python objects, so they can be freely mixed with Column(...) output and raw dictionaries in the same groups list.

Examples

>>> ColumnGroup("profile", title="Profile", columns=["name", "team"])
{'id': 'profile', 'columns': ['name', 'team'], 'title': 'Profile'}