I’m using NiceGUI and trying to create a table with a dynamic title. I want to be able to change the title of the table dynamically, just like I can update the columns and rows properties.
# Create the table with an initial title
existing_table_route = ui.table(
columns=[],
rows=[],
row_key='Route/Variant',
title="Existing - Rate / SKU - Routewise"
).classes('my-table-style-1').style('text-align:right;')
# Function to update the table title dynamically
def update_table_title(new_title):
existing_table_route.title = new_title # Update the title
existing_table_route.update() # Refresh the table to reflect the title change
# Button to dynamically change the title
ui.button('Change Title', on_click=lambda: update_table_title('New Dynamic Table Title'))
However, when I attempt to change the title dynamically using the update_table_title() function, it does not seem to update the table’s title as expected.
Steps I tried:
-
Updated the
titleattribute of the table directly. -
Called
existing_table_route.update()to refresh the table. -
The title does not change when I click the "Change Title" button.
Expected behavior:
- I expect the table’s title to update dynamically when I call
update_table_title().
Questions:
-
Is there a known issue with dynamically updating the
titleattribute of a table in NiceGUI? -
How can I correctly change the table’s title dynamically, similar to how you can update
columnsandrows?
Any help or insights would be greatly appreciated!
–
>Solution :
There is no title property in ui.table, that’s why nothing happens when you assign a value to it.
Instead you can update the "title" prop like this:
ui.button('Change Title',
on_click=lambda: existing_table_route.props('title="New Dynamic Table Title"'))