dash-pivottable icon indicating copy to clipboard operation
dash-pivottable copied to clipboard

Can't get state value of valueFilter

Open nadavchernin opened this issue 1 year ago • 0 comments

Description

I need to get valueFilter which changed by user But instead got {}

Steps/Code to Reproduce

from dash import html, Output, Input, State
import dash_pivottable

app = dash.Dash(__name__)
server = app.server
import dash_bootstrap_components as dbc
app.layout = html.Div(children=[
    dbc.Button('Press',id='button'),
    html.Div(id="my-div",children=
    [
        dash_pivottable.PivotTable(id="pivot",
        data=[
            ['Animal', 'Count', 'Location'],
            ['Zebra', 5, 'SF Zoo'],
            ['Tiger', 3, 'SF Zoo'],
            ['Zebra', 2, 'LA Zoo'],
            ['Tiger', 4, 'LA Zoo'],
        ],
        cols=["Animal"],
        rows=["Location"],
        vals=["Count"],
        valueFilter={}

    )]
)])

@app.callback(
    Output("my-div", 'children'),
    Input('button', 'n_clicks'),
    State("pivot","cols"),
    State("pivot", "rows"),
    State("pivot", "vals"),
    State("pivot", "valueFilter"),
)
def refresh(n_clicks,cols,rows,vals,filter):
    print(filter)
    print(f"Click={n_clicks}")
    ret=html.Div(children=dash_pivottable.PivotTable(
        id=f"pivot",
        data=[
            ['Animal', 'Count', 'Location'],
            ['Zebra', n_clicks, 'SF Zoo'],
            ['Tiger', n_clicks, 'SF Zoo'],
            ['Zebra', n_clicks, 'LA Zoo'],
            ['Tiger', n_clicks, 'LA Zoo'],
        ],
        cols=cols,
        rows=rows,
        vals=vals,
        valueFilter=filter
    ),id=f"pivot_div_{n_clicks}",)
    return ret
if __name__ == "__main__":
    app.run_server(debug=True)

Expected Results

Actual Results

Versions

nadavchernin avatar Mar 27 '24 13:03 nadavchernin