use_cell_data
use_cell_data lets you use the cell data of the first cell (first row in the first column) in a table. This is useful when you want to listen to an updating table and use the data in your component.
Example
In the above example, ui_table_first_cell is a component that listens to the last row of a table and displays the value of the first cell. The cell_value variable is updated every time the table updates.
Recommendations
- Use
use_cell_datafor listening to table updates: If you need to listen to a table for one cell of data, useuse_cell_data. - Use table operations to filter to one cell: Because
use_cell_dataalways uses the top-left cell of the table, you can filter your table to determine what cell to listen to. If your table has multiple rows and columns, use table operations such as.where,.selectand.reverseto filter to the desired cell.
Empty tables
If the table is empty, the value of cell_value will return the value of None.
You can optionally provide a sentinel value to return when the table is empty instead.
Null values
If the table cell is a null value, the value of cell_value will be pandas.NA. You can check for null values using the pandas.isna function.
Return the first cell of the table. The table should already be filtered to only have a single cell.
Returns: Any The first cell of the table.
| Parameters | Type | Default | Description |
|---|---|---|---|
| table | Table | None | The table to extract the cell from. | |
| sentinel | Any | None | The sentinel value to return if the table is ticking but empty. Defaults to None. |