Skip to content

MultiSelect

pywry.toolbar.MultiSelect

Bases: ToolbarItem

A multi-select dropdown with checkboxes.

Emits {values: [...], componentId: ...} on selection change.

Selected items appear at the top of the dropdown, unselected items below.

ATTRIBUTE DESCRIPTION
options

List of Option items for the dropdown.

TYPE: list of Option

selected

Currently selected values.

TYPE: list of str

Examples:

>>> MultiSelect(
...     label="Columns:",
...     event="columns:filter",
...     options=[Option(label="Name"), Option(label="Age"), Option(label="City")],
...     selected=["Name", "Age"],
... )

Functions

normalize_options classmethod

normalize_options(v: Any) -> list[Option]

Accept list of dicts or Option objects.

normalize_selected classmethod

normalize_selected(v: Any) -> list[str]

Convert single string to list.

build_html

build_html() -> str

Build multiselect dropdown HTML with checkboxes.

auto_generate_component_id

auto_generate_component_id() -> ToolbarItem

Auto-generate component_id based on type if not provided.

validate_event_name classmethod

validate_event_name(v: str) -> str

Validate event follows namespace:event-name pattern.