|
@@ -239,6 +239,37 @@ def handle_pagination_changes() -> None:
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
+@doc.demo('Computed props', '''
|
|
|
|
+ You can access the computed props of a table within async callback functions.
|
|
|
|
+''')
|
|
|
|
+def computed_props():
|
|
|
|
+ async def show_filtered_sorted_rows():
|
|
|
|
+ ui.notify(await table.get_filtered_sorted_rows())
|
|
|
|
+
|
|
|
|
+ async def show_computed_rows():
|
|
|
|
+ ui.notify(await table.get_computed_rows())
|
|
|
|
+
|
|
|
|
+ table = ui.table(
|
|
|
|
+ columns=[
|
|
|
|
+ {'name': 'name', 'label': 'Name', 'field': 'name', 'align': 'left', 'sortable': True},
|
|
|
|
+ {'name': 'age', 'label': 'Age', 'field': 'age', 'align': 'left', 'sortable': True}
|
|
|
|
+ ],
|
|
|
|
+ rows=[
|
|
|
|
+ {'name': 'Noah', 'age': 33},
|
|
|
|
+ {'name': 'Emma', 'age': 21},
|
|
|
|
+ {'name': 'Rose', 'age': 88},
|
|
|
|
+ {'name': 'James', 'age': 59},
|
|
|
|
+ {'name': 'Olivia', 'age': 62},
|
|
|
|
+ {'name': 'Liam', 'age': 18},
|
|
|
|
+ ],
|
|
|
|
+ row_key='name',
|
|
|
|
+ pagination=3,
|
|
|
|
+ )
|
|
|
|
+ ui.input('Search by name/age').bind_value(table, 'filter')
|
|
|
|
+ ui.button('Show filtered/sorted rows', on_click=show_filtered_sorted_rows)
|
|
|
|
+ ui.button('Show computed rows', on_click=show_computed_rows)
|
|
|
|
+
|
|
|
|
+
|
|
@doc.demo('Computed fields', '''
|
|
@doc.demo('Computed fields', '''
|
|
You can use functions to compute the value of a column.
|
|
You can use functions to compute the value of a column.
|
|
The function receives the row as an argument.
|
|
The function receives the row as an argument.
|