Insert rows to datatable. :param str instance_id: Datatable instance id (i.e., the ``instance_id`` parameter when calling :py:func:`put_datatable()`) :param dict/list[dict] records: row record or row record list to insert :param str/int row_id: row id to insert before, if n
(instance_id: str, records: List, row_id=None)
| 1748 | |
| 1749 | |
| 1750 | def datatable_insert(instance_id: str, records: List, row_id=None): |
| 1751 | """ |
| 1752 | Insert rows to datatable. |
| 1753 | |
| 1754 | :param str instance_id: Datatable instance id |
| 1755 | (i.e., the ``instance_id`` parameter when calling :py:func:`put_datatable()`) |
| 1756 | :param dict/list[dict] records: row record or row record list to insert |
| 1757 | :param str/int row_id: row id to insert before, if not specified, insert to the end |
| 1758 | |
| 1759 | Note: |
| 1760 | When use ``id_field=None`` (default) in :py:func:`put_datatable()`, the row id of new inserted rows will |
| 1761 | auto increase from the last max row id. |
| 1762 | """ |
| 1763 | from .session import run_js |
| 1764 | |
| 1765 | if not isinstance(records, (list, tuple)): |
| 1766 | records = [records] |
| 1767 | |
| 1768 | instance_id = f"ag_grid_{instance_id}_promise" |
| 1769 | run_js("""window[instance_id] ? window[instance_id].then((grid) => { |
| 1770 | let row = grid.api.getRowNode(row_id); |
| 1771 | let idx = row ? row.rowIndex : null; |
| 1772 | grid.api.applyTransaction({ |
| 1773 | add: records.map((row) => grid.flatten_row(row)), |
| 1774 | addIndex: idx, |
| 1775 | }); |
| 1776 | }) : console.error(`Datatable instance [${instance_id}] not found`); |
| 1777 | """, instance_id=instance_id, records=records, row_id=row_id) |
| 1778 | |
| 1779 | |
| 1780 | def datatable_remove(instance_id: str, row_ids: List): |
nothing calls this directly
no test coverage detected
searching dependent graphs…