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

How to work with dynamic callbacks in Dash?

$
0
0

I have a Dash application where the items of a ListGroup are generated dynamically, based on the length of a certain file. The file can have different lengths. I have added the items to the list, each of them having a unique id, based on its position in the file.
Here I am appending the items from file to the list group.

output.append(dbc.ListGroupItem(row_value, id=str(row_number), n_clicks=0, action=True))

I have a callback where I need to know the length of listgroup items, but I don’t know the length of them in the Input of the callback. How can I solve this problem?
This is the dynamic callback:

@app.callback(
    [Output("counter", "children"), Output("sparql_query", "value")],
    [Input(str(i), "n_clicks") for i in range(prefixes_count)],
    [Input(str(i), "children") for i in range(prefixes_count)],
    State('sparql_query', 'value'), prevent_initial_call=True
)

I need to set the prefixes_count beforehand. I was thinking of using a helper div where to store the prefixes_count value, but how can I access it in the previous callback ? I was thinking of something like this, but obviously this is not working:

range(Input('length_children_tab', 'children'))

How can I reach the same effect?

7 posts - 3 participants

Read full topic


Viewing all articles
Browse latest Browse all 6271

Latest Images

Trending Articles



Latest Images