Skip to content

Commit

Permalink
zauberzeug#242 add documentation for table.call_api_method
Browse files Browse the repository at this point in the history
  • Loading branch information
falkoschindler committed Feb 10, 2023
1 parent d0a27da commit 9a1f418
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions nicegui/elements/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ def __init__(self, options: Dict, *, html_columns: List[int] = [], theme: str =
An element to create a table using `AG Grid <https://www.ag-grid.com/>`_.
The `call_api_method` method can be used to call an AG Grid API method.
:param options: dictionary of AG Grid options
:param html_columns: list of columns that should be rendered as HTML (default: `[]`)
:param theme: AG Grid theme (default: 'balham')
Expand All @@ -31,4 +33,11 @@ def update(self) -> None:
self.run_method('update_grid')

def call_api_method(self, name: str, *args) -> None:
"""Call an AG Grid API method.
See `AG Grid API <https://www.ag-grid.com/javascript-data-grid/grid-api/>`_ for a list of methods.
:param name: name of the method
:param args: arguments to pass to the method
"""
self.run_method('call_api_method', name, *args)
2 changes: 2 additions & 0 deletions website/reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,15 @@ def table_example():
{'name': 'Bob', 'age': 21},
{'name': 'Carol', 'age': 42},
],
'rowSelection': 'multiple',
}).classes('max-h-40')

def update():
table.options['rowData'][0]['age'] += 1
table.update()

ui.button('Update', on_click=update)
ui.button('Select all', on_click=lambda: table.call_api_method('selectAll'))

@example(ui.chart, menu)
def chart_example():
Expand Down

0 comments on commit 9a1f418

Please sign in to comment.