Quantcast
Channel: 🎛️ Dash - Plotly Community Forum
Viewing all articles
Browse latest Browse all 6271

How to register callbacks inside a function

$
0
0

@yuricda96 wrote:

I’m in the following situation. My team made a framework that has a global app that parses a URL and, with the query params, selects the dashboard to render. On a specific one, the number of filters is dynamic, so we made a dynamic callback creation using a function found on this community forum. The problem is: Initially we don’t have the number of filters we need, so we have to compute it on a function and, after that, register the associated callback. But, declaring the decorator inside the function was not working. Does anyone know how to declare the decorator after I have the number of filters?

Example:
I used an example with a fixed number of 5 filters, registering it globally:

app.callback(
[Output(‘predictive-switch-{}’.format(i),‘value’) for i in range(5)],
[Input(‘predictive-trash-{}’.format(i), ‘n_clicks’) for i in range(5)]
)(remove_predictive_filter_option_callback)

And it works, but calculating the number of filters inside the rendering function and, after that, register the callback on this form:

app.callback(
[Output(‘predictive-switch-{}’.format(i),‘value’) for i in range(NUM_FILTERS)],
[Input(‘predictive-trash-{}’.format(i), ‘n_clicks’) for i in range(NUM_FILTERS)]
)(remove_predictive_filter_option_callback)
it dont register the callback on the app.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 6271

Latest Images

Trending Articles



Latest Images