Skip to content

How to refresh/update/redraw table with changed values #1307

Closed Answered by falkoschindler
HerzMichi asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @HerzMichi,
The table has no reference to var_age. So if its value changes, the cell value will still be 23.
But if you update the rows, you only need to call table.update to send the new data to the browser:

var_age = 23

columns = [
    {'name': 'name', 'label': 'Name', 'field': 'name', 'required': True, 'align': 'left'},
    {'name': 'age', 'label': 'Age', 'field': 'age', 'sortable': True},
]
rows = [
    {'name': 'Alice', 'age': 18},
    {'name': 'Bob', 'age': 21},
    {'name': 'Carol', 'age': var_age},
]
table = ui.table(columns=columns, rows=rows, row_key='name')

def handle_click():
    global var_age
    var_age += 1
    rows[2]['age'] = var_age
    table.update()

ui.button('C…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@HerzMichi
Comment options

Answer selected by HerzMichi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants