use_table_data
use_table_data
lets you use the data of a table. This is useful when you want to listen to an updating table and use the data in your component.
Example
from deephaven import time_table, ui
@ui.component
def ui_table_data(table):
table_data = ui.use_table_data(table)
return ui.heading(f"The table data is {table_data}")
table_data = ui_table_data(time_table("PT1s").update("x=i").tail(5))
In the above example, ui_table_data
is a component that listens to the last 5 rows of a table and displays the data. The table_data
variable is updated every time the table updates.
Recommendations
- Use
use_table_data
for listening to table updates: If you need to listen to a table for all the data, useuse_table_data
. - Use table operations to filter to the data you want: If your table has multiple rows and columns, use table operations such as
.where
and.select
to filter to the data you want to listen to.
API Reference
Returns a dictionary with the contents of the table. Component will redraw if the table changes, resulting in an updated frame.
Returns: Dict[str, List[Any]] | Any
The table data or the sentinel value.
Parameters | Type | Default | Description |
---|---|---|---|
table | Table | None | The table to listen to. If None, None will be returned, not the sentinel value. | |
sentinel | Any | () | The sentinel value to return if the table is ticking but empty. Defaults to an empty tuple. |
transform | Callable[[DataFrame | Any | None, bool], Any] | None | None | A function to transform the table data and is_sentinel values. Defaults to None, which will return the data as TableData. |