Skip to content

how to sum selected columns in data table #839

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

You must be logged in to vote

The problem is, that the filter is evaluated on the client and currently the result is not sent to the server.

We can try to reproduce the filter on the server (with the risk of filtering slightly different rows in edge cases):

def update_total():
    search = state.filter.lower()
    total.text = sum(row['age'] for row in rows if any(search in str(cell).lower() for cell in row.values()))

filter = ui.input(label="Filter Table", placeholder="filter text", on_change=update_total).bind_value(state, 'filter')
with ui.table(columns=columns, rows=rows, row_key='name').bind_filter_from(state) as table:
    with table.add_slot('bottom-row'):
        with table.row():
            with table.cell(…

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
5 replies
@tofusoul
Comment options

@tofusoul
Comment options

@tofusoul
Comment options

@falkoschindler
Comment options

Answer selected by tofusoul
@tofusoul
Comment options

Comment options

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

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