Output a datatable. Compared with `put_table()`, `put_datatable()` is more suitable for displaying large amounts of data (both data fields and data entries), while `put_table()` is more suitable for displaying diverse data types (pictures, buttons, etc.) in cells. This widget
(
records: SequenceType[MappingType],
actions: SequenceType[Tuple[str, Callable[[Union[str, int, List[Union[str, int]]]], None]]] = None,
onselect: Callable[[Union[str, int, List[Union[str, int]]]], None] = None,
multiple_select=False,
id_field: str = None,
height: Union[str, int] = 600,
theme: "Literal['alpine', 'alpine-dark', 'balham', 'balham-dark', 'material']" = 'balham',
cell_content_bar=True,
instance_id='',
column_order: Union[SequenceType[str], MappingType] = None,
column_args: MappingType[Union[str, Tuple], MappingType] = None,
grid_args: MappingType[str, Any] = None,
enterprise_key='',
scope: str = None,
position: int = OutputPosition.BOTTOM
)
| 1483 | |
| 1484 | |
| 1485 | def put_datatable( |
| 1486 | records: SequenceType[MappingType], |
| 1487 | actions: SequenceType[Tuple[str, Callable[[Union[str, int, List[Union[str, int]]]], None]]] = None, |
| 1488 | onselect: Callable[[Union[str, int, List[Union[str, int]]]], None] = None, |
| 1489 | multiple_select=False, |
| 1490 | id_field: str = None, |
| 1491 | height: Union[str, int] = 600, |
| 1492 | theme: "Literal['alpine', 'alpine-dark', 'balham', 'balham-dark', 'material']" = 'balham', |
| 1493 | cell_content_bar=True, |
| 1494 | instance_id='', |
| 1495 | column_order: Union[SequenceType[str], MappingType] = None, |
| 1496 | column_args: MappingType[Union[str, Tuple], MappingType] = None, |
| 1497 | grid_args: MappingType[str, Any] = None, |
| 1498 | enterprise_key='', |
| 1499 | scope: str = None, |
| 1500 | position: int = OutputPosition.BOTTOM |
| 1501 | ) -> Output: |
| 1502 | """ |
| 1503 | Output a datatable. |
| 1504 | |
| 1505 | Compared with `put_table()`, `put_datatable()` is more suitable for displaying large amounts of data |
| 1506 | (both data fields and data entries), while `put_table()` is more suitable for displaying diverse data types |
| 1507 | (pictures, buttons, etc.) in cells. |
| 1508 | |
| 1509 | This widget is powered by the awesome `ag-grid <https://www.ag-grid.com/>`_ library. |
| 1510 | |
| 1511 | :param list[dict] records: data of rows, each row is a python ``dict``, which can be nested. |
| 1512 | :param list actions: actions for selected row(s), they will be shown as buttons when row is selected. |
| 1513 | The format of the action item: `(button_label:str, on_click:callable)`. |
| 1514 | Specifically, ``None`` item is allowed, which will be rendered as a separator. |
| 1515 | The ``on_click`` callback receives the selected row ID as parameter. |
| 1516 | :param callable onselect: callback when row is selected, receives the selected row ID as parameter. |
| 1517 | :param bool multiple_select: whether multiple rows can be selected. |
| 1518 | When enabled, the ``on_click`` callback in ``actions`` and the ``onselect`` callback will receive |
| 1519 | ID list of selected rows as parameter. |
| 1520 | :param str/tuple id_field: row ID field, that is, the key of the row dict to uniquely identifies a row. |
| 1521 | When not provide, the datatable will use the index in ``records`` to assign row ID. |
| 1522 | |
| 1523 | .. collapse:: Notes when the row record is nested dict |
| 1524 | |
| 1525 | To specify the ID field of a nested dict, use a tuple to specify the path of the ID field. |
| 1526 | For example, if the row record is in ``{'a': {'b': ...}}`` format, you can use ``id_field=('a', 'b')`` |
| 1527 | to set ``'b'`` column as the ID field. |
| 1528 | |
| 1529 | :param int/str height: widget height. When pass ``int`` type, the unit is pixel, |
| 1530 | when pass ``str`` type, you can specify any valid CSS height value. |
| 1531 | In particular, you can use ``'auto'`` to make the datatable auto-size it's height to fit the content. |
| 1532 | :param str theme: datatable theme. |
| 1533 | Available themes are: ``'balham'`` (default), ``'alpine'``, ``'alpine-dark'``, ``'balham-dark'``, ``'material'``. |
| 1534 | You can preview the themes in `ag-grid official example <https://www.ag-grid.com/example/?theme=ag-theme-balham>`_. |
| 1535 | :param bool cell_content_bar: whether to add a text bar to datatable to show the content of current focused cell. |
| 1536 | Default is ``True``. |
| 1537 | :param str instance_id: Assign a unique ID to the datatable, so that you can refer this datatable in |
| 1538 | `datatable_update()`, `datatable_insert()` and `datatable_remove()` functions. |
| 1539 | |
| 1540 | :param list column_order: column order, the order of the column names in the list will be used as the column order. |
| 1541 | If not provided, the column order will be the same as the order of the keys in the first row of ``records``. |
| 1542 | When provided, the column not in the list will not be shown. |
nothing calls this directly
no test coverage detected
searching dependent graphs…