tables module

class EditingTable(label, inputs, states, get_data_func, update_table_func=None, output=None, output_varselector_name=None, number_format=None, **kwargs)

Bases: object

A component for editing data using a Dash AgGrid table.

This class provides a layout and functionality to: - Load a dataframe into an editable Dash AgGrid table. - Update data based on user edits in the table with a custom function.

Parameters:
  • label (str)

  • inputs (list[str])

  • states (list[str])

  • get_data_func (Callable[[...], Any])

  • update_table_func (Callable[[...], Any] | None)

  • output (str | list[str] | None)

  • output_varselector_name (str | list[str] | None)

  • number_format (str | None)

  • kwargs (Any)

label

The label for the tab or component.

Type:

str

output

Identifier for the table, used for callbacks.

Type:

str | None

output_varselector_name

Identifier for the variable selector.

Type:

str | None

variableselector

A variable selector for managing inputs and states.

Type:

VariableSelector

get_data

Function to fetch data from the database.

Type:

Callable[…, Any]

update_table

Function to update database records based on edit made in the table.

Type:

Callable[…, Any]

module_layout

The layout of the component.

Type:

html.Div

number_format

A d3 format string for formatting numeric values in the table.

Type:

str

layout()

Define the layout for the EditingTable module.

Because this module can be used as a a component in other modules, it needs to have a layout method that is not abstract. For implementations as tab or window, this method should still be overridden.

Returns:

A Dash HTML Div component representing the layout of the module to be displayed directly.

Return type:

html.Div

module_callbacks()

Register Dash callbacks for the EditingTable component.

Return type:

None

Notes

  • The load_ag_grid callback loads data into the table based on the selected table and filter states.

  • The update_table callback updates database values when a cell value is changed.

class EditingTableTab(label, inputs, states, get_data_func, update_table_func=None, output=None, output_varselector_name=None, number_format=None, **kwargs)

Bases: TabImplementation, EditingTable

A class to implement a module inside a tab.

Parameters:
  • label (str)

  • inputs (list[str])

  • states (list[str])

  • get_data_func (Callable[[...], Any])

  • update_table_func (Callable[[...], Any] | None)

  • output (str | None)

  • output_varselector_name (str | None)

  • number_format (str | None)

  • kwargs (Any)

class EditingTableWindow(label, inputs, states, get_data_func, update_table_func=None, output=None, output_varselector_name=None, number_format=None, **kwargs)

Bases: WindowImplementation, EditingTable

A class to implement an EditingTable module inside a modal.

It is used to create a modal window containing an EditingTable. This class inherits from both EditingTable and WindowImplementation, where WindowImplementation is a mixin that handles the modal functionality.

Parameters:
  • label (str)

  • inputs (list[str])

  • states (list[str])

  • get_data_func (Callable[[...], Any])

  • update_table_func (Callable[[...], Any] | None)

  • output (str | None)

  • output_varselector_name (str | None)

  • number_format (str | None)

  • kwargs (Any)