October 22, 2024
Chicago 12, Melborne City, USA
python

NiceGUI Table Dynamic Title


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 title attribute 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 title attribute of a table in NiceGUI?

  • How can I correctly change the table’s title dynamically, similar to how you can update columns and rows?

Any help or insights would be greatly appreciated!



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video