|
@@ -140,3 +140,21 @@ def more() -> None:
|
|
|
columns=[{'name': col, 'label': col, 'field': col} for col in df.columns],
|
|
|
rows=df.to_dict('records'),
|
|
|
)
|
|
|
+
|
|
|
+ @text_demo('Adding Rows', '''
|
|
|
+ It's simple to add new rows with the `add_rows(dict)` method.
|
|
|
+ ''')
|
|
|
+ def adding_rows():
|
|
|
+ import os
|
|
|
+ import random
|
|
|
+
|
|
|
+ def add():
|
|
|
+ item = os.urandom(10 // 2).hex()
|
|
|
+ table.add_rows({'item_id': item, 'count': random.randint(0, 100)})
|
|
|
+
|
|
|
+ ui.button('add', on_click=add)
|
|
|
+ columns = [
|
|
|
+ {'name': 'item_id', 'label': 'Id', 'field': 'item_id'},
|
|
|
+ {'name': 'count', 'label': 'Count', 'field': 'count'},
|
|
|
+ ]
|
|
|
+ table = ui.table(columns=columns, rows=[], row_key='item_id').classes('w-full')
|