Skip to content

table class

Displays a data set as tabular data.

Methods

__init__()

__init__(
    data=None,
    page_size=100,
    allow_all_rows=False,
    show_all=False,
    auto_loading=False,
    selected=None,
    page_size_options=[50, 100, 500],
    columns=None, # All columns
    date_format="MM/dd/yyyy",
    number_format=None,
    row_class_name=None,
    tooltip=None,
    width="100%",
    height="80vh",
    filter=False,
    nan_value="",
    editable=False,
    on_edit=None, # default implementation
    on_add=None,
    on_delete=None, # default implementation
    on_action=None,
    size="small",
    rebuild=False,
    downloadable=False,
    on_compare=None,
    use_checkbox=False,
    sortable=True,
    active=True,
    id=None,
    properties=None,
    class_name=None,
    hover_text=None,
) -> None

Create a new table element.

Parameters:

Name Type Description Default

data

Any
dynamic

The data to be represented in this table. This property can be indexed to define other data for comparison.

None

page_size

int

For a paginated table, the number of visible rows.

100

allow_all_rows

bool

For a paginated table, adds an option to show all the rows.

False

show_all

bool

For a paginated table, show all the rows.

False

auto_loading

bool

If True, the data will be loaded on demand.

False

selected

Union[list[int],str]
dynamic

The list of the indices of the rows to be displayed as selected.

None

page_size_options

Union[list[int], str]

The list of available page sizes that users can choose from.

[50, 100, 500]

columns

Union[str, list[str], dict[str, dict[str, Union[str, int]]]]

The list of the column names to display.

  • str: semicolon (';')-separated list of column names.
  • list[str]: the list of column names.
  • dict: a dictionary with entries matching: {"<column_name>": {"format": "<format>", "index": 1}}.
    if index is specified, it represents the display order of this column. If index is not specified, the list order defines the index.
    If format is specified, it is used for numbers or dates.

If columns is omitted or set to None, all columns of data are represented.


All columns

date_format

str

The date format used for all date columns when the format is not specifically defined.

MM/dd/yyyy

number_format

str

The number format used for all number columns when the format is not specifically defined.

None

row_class_name

Union[str, Callable]

Allows for styling rows.
This property must be a function or the name of a function that return the name of a CSS class for table rows.
This function is invoked with the following parameters:

  • state (State): the state instance.
  • index (int): the index of the row.
  • row (Any): all the values for this row.

See below for more details.

None

tooltip

Union[str, Callable]

Enables tooltips on cells.
This property must be a function or the name of a function that must return a tooltip text for a cell.
See below for more details.

None

width

str

The width of this table control, in CSS units.

100%

height

str

The height of this table control, in CSS units.

80vh

filter

bool

Indicates, if True, that all columns can be filtered.

False

nan_value

str

The replacement text for NaN (not-a-number) values.

editable

bool
dynamic

Indicates, if True, that all cells can be edited.

False

on_edit

Union[bool, Callable]

A function or the name of a function triggered when an edited cell is validated.
This function is invoked with the following parameters:

  • state (State): the state instance.
  • var_name (str): the name of the tabular data variable.
  • payload (dict): a dictionary containing details about the callback invocation, with the following keys:
    • index (int): the row index.
    • col (str): the column name.
    • value (Any): the new cell value, cast to the column's data type.
    • user_value (str): the new cell value, as entered by the user.
    • tz (str): the timezone, if the column type is date.
If this property is set to False, the table does not provide the cell editing functionality.
If this property is not set, the table will use the default implementation for editing cells.

default implementation

on_add

Union[bool, Callable]

A function or the name of a function that is triggered when the user requests a row to be added to the table.
This function is invoked with the following parameters:

  • state (State): the state instance.
  • var_name (str): the name of the tabular data variable.
  • payload (dict): the details on this callback's invocation.
    This dictionary has the following key:
    • index (int): the row index.

If this property is not set, the table uses the default implementation for adding a new row
If this property is set to False, you cannot add new rows.


None

on_delete

Union[bool, Callable]

A function or the name of a function triggered when a row is deleted.
This function is invoked with the following parameters:

  • state (State): the state instance.
  • var_name (str): the name of the tabular data variable.
  • payload (dict): the details on this callback's invocation.
    This dictionary has one key:
    • index (int): the row index.

If this property is not set, the table uses the default implementation for deleting rows.


default implementation

on_action

Union[str, Callable]

A function or the name of a function that is triggered when the user selects a row.
This function is invoked with the following parameters:

  • state (State): the state instance.
  • var_name (str): the name of the tabular data variable.
  • payload (dict): the details on this callback's invocation.
    This dictionary has the following keys:
    • action: the name of the action that triggered this callback.
    • index (int): the row index.
    • col (str): the column name.
    • reason (str): the origin of the action: "click", or "button" if the cell contains a Markdown link syntax.
    • value (str): the link value indicated in the cell when using a Markdown link syntax (that is, reason is set to "button").

.

None

size

str

The size of the rows.
Valid values are "small" and "medium".

small

rebuild

bool
dynamic

If set to True, this allows to dynamically refresh the columns.

False

downloadable

bool

If True, a clickable icon is shown so the user can download the data as CSV.

False

on_compare

Union[str, Callable]

A function or the name of a function that compares data. This function should return a structure that identifies the differences between the different data passed as name. The default implementation compares the default data with the data[1] value.

None

use_checkbox

bool

If True, boolean values are rendered as a simple HTML checkbox.

False

sortable

bool

If False, the table provides no sorting capability. Individual columns can override this global setting, allowing specific columns to be marked as sortable or non-sortable regardless of value of sortable, by setting the sortable property to True or False accordingly, in the dictionary for that column in the columns property value.

True

active

bool
dynamic

Indicates if this component is active.
An inactive component allows no user interaction.

True

id

str

The identifier that is assigned to the rendered HTML component.

None

properties

dict[str, Any]

Bound to a dictionary that contains additional properties for this element.

None

class_name

str
dynamic

The list of CSS class names that are associated with the generated HTML Element.
These class names are added to the default taipy-table class name.

None

hover_text

str
dynamic

The information that is displayed when the user hovers over this element.

None