Table View
The TableView displays data in a standard table layout. In most models you do not instantiate TableView directly.
Instead, create it via the UiBuilder API, UiBuilder.add_table_view(),
which registers the view with the UI definition and ensures it is included in the build output.
- class TableView(table, display_name=None, hidden=False)[source]
Bases:
BaseTableViewA UI component that displays data in a tabular format with rows and columns
Designed to resemble a spreadsheet or Excel-like interface, TableView supports structured data presentation, allowing for features like sorting, filtering, cell formatting, and interactive editing.
- filter_mode
An optional filtering strategy applied to the table.
- Type:
Optional[daitum_ui.data.FilterMode]
- __init__(table, display_name=None, hidden=False)[source]
Initializes a TableView with an underlying table and optional settings.
- add_field(field_id, readonly=False, allow_reset=False)[source]
Adds a column to the table view.
- Parameters:
- Returns:
The constructed view field.
- Return type:
ViewField- Raises:
ValueError – If the field ID does not exist in the source table.
Supporting Types
- class ViewField(field_id, readonly=False)[source]
Bases:
BuildableDefines the configuration and behaviour of a single field within a view.
This class acts as a declarative definition only; it does not contain any runtime UI logic. All configuration is serialized via Buildable for consumption by the UI renderer.
- Parameters:
field_id (
str) – The unique identifier of the underlying data field.display_name (Optional[str | Parameter | Calculation], optional) – The display label for the field. May be a static string or a reference to a named value (parameter or calculation). Defaults to None.
readonly (
bool|Field) – Controls whether the field is read-only. If a boolean is provided, the field is always read-only or editable. If a Field is provided, its value is used as a dynamic read-only condition. Defaults to False.
- set_display_name(name)[source]
Sets the display label for this field.
- Return type:
ViewField
- set_column_hide_variable(column_hide_variable)[source]
Sets the context variable that controls column visibility.
- Return type:
ViewField
- set_width(width)[source]
Sets the column width in pixels.
- Return type:
ViewField
- set_header_column(header_column)[source]
Sets whether this field is treated as a header column.
- Return type:
ViewField
- set_display_field(display_field)[source]
Sets an alternative field to display instead of the underlying field value.
- Return type:
ViewField
- set_on_click_event(event)[source]
Assigns an editor event to be triggered when the editor is clicked.
- Parameters:
event (
ModelEvent) – The event to execute on editor click.- Raises:
ValueError – If an editor event has already been set.
- Return type:
ViewField
- set_on_change_event(event)[source]
Assigns an editor event to be triggered when the editor’s value changes.
- Parameters:
event (
ModelEvent) – The event to execute on editor value change.- Raises:
ValueError – If an editor event has already been set.
- Return type:
ViewField
- set_list_validation(reference_field)[source]
Sets a list-based data validation rule for this field.
- Parameters:
reference_field (
str) – The name of the field that provides the list of valid values.- Return type:
ViewField
- set_range_validation(min_value=None, max_value=None, flag=ValidationFlag.INCLUSIVE)[source]
Sets a range-based data validation rule for this field.
- Parameters:
min_value (
str|Value|None) – A fixed Value or the name of the field or named value providing min value dynamically.max_value (
str|Value|None) – A fixed Value or the name of the field or named value providing max value dynamically.flag (
ValidationFlag) – Whether the boundaries are inclusive or exclusive. Defaults to INCLUSIVE.
- Return type:
ViewField
- add_conditional_formatting_rule(condition_column, override_styles, element_states=None, stop_if_true=False, formatting_type=ConditionalFormattingType.BOOLEAN)[source]
Adds a new conditional formatting rule to the current configuration.
The rule applies specified style overrides to a column when a condition based on another column’s value is met. Optionally, further rules can be stopped from processing once this rule evaluates as true.
- Parameters:
condition_column (
str) – The name of the column whose value is evaluated as the condition for applying this formatting rule.override_styles (
ColumnStyle) – The styles to apply when the condition is true. These styles override the existing column styles.element_states (
ElementStates|None) – The element state to apply if the condition is met.stop_if_true (
bool) – If True, no further conditional formatting rules will be applied after this rule if its condition evaluates to true. Defaults to False.formatting_type (
ConditionalFormattingType) – The type of condition to apply (e.g., BOOLEAN, AFTER_TODAY, BEFORE_TODAY). Defaults to ConditionalFormattingType.BOOLEAN.
- Return type:
ViewField
- set_default_value_reference(value, behaviour=DefaultValueBehaviour.DEFAULT)[source]
Set the default value reference for this field.
This configures a reference value that can be used to reset the field’s value to a predefined default. The reference can either be another field or a named value, with an associated behaviour determining how the reset behaves in the UI.
- Parameters:
value (
Field|Parameter|Calculation) – The source of the default value. If a Field instance, the reference type is set to FIELD; otherwise, it is treated as a NAMED_VALUE.behaviour (
DefaultValueBehaviour) – Controls the behavior of the default value override, such as showing a reset icon. Defaults to DefaultValueBehaviour.DEFAULT.
- Return type:
ViewField
- set_edit_override(target_reference_field, target_field_id, map_key_field=None)[source]
Set an edit override that redirects edits from the visible table to another underlying table.
This is required when the field being edited does not directly belong to the displayed table, but rather to a related table referenced by a field.
- Parameters:
target_reference_field (
str) – The field in the displayed table containing a reference to the row/table to edit.target_field_id (
str) – The field ID in the referenced table where the actual value should be edited.map_key_field (
str|None) – If the target field is a map-type, this field contains the map key to identify the correct entry. Defaults to None.
- Return type:
ViewField
- set_cell_style(**kwargs)[source]
Update the styling properties for the cells in this column.
This method ensures that the column_style object exists and then updates its attributes based on the provided keyword arguments.
- Parameters:
**kwargs – Style attributes to set on the column’s cell style.
- Return type:
ViewField
- set_header_style(**kwargs)[source]
Update the styling properties for the header cell of this column.
Ensures that the header_style is initialized before applying updates.
- Parameters:
**kwargs – Style attributes to set on the column header’s style.
- Return type:
ViewField
- set_read_only_style(**kwargs)[source]
Update the styling properties applied when this column is read-only.
Ensures that the read_only_style is initialized before applying updates.
- Parameters:
**kwargs – Style attributes to set on the read-only column style.
- Return type:
ViewField
- set_column_config(frozen=None, editor=None)[source]
Configure column-level settings such as freezing behavior and editor configuration.
This method ensures the column style is initialized, then applies the provided settings to control whether the column is frozen (i.e., remains visible during horizontal scrolling) and/or sets the editor used for the column’s cells.
- Parameters:
frozen (
bool|None) – If provided, sets whether the column is frozen. A frozen column stays fixed during horizontal scroll. If None, the frozen setting is not modified.editor (
Editor|None) – If provided, assigns the editor configuration to be used for the column’s cells. If None, the editor setting is not modified.
- Return type:
ViewField