Function to update layout dynamically

The number of dropdowns my application has depends on how many columns a given table contains, and these columns change from case to case. My main purpose is to make the whole code as dynamical as possible. I thought about creating a function that receives this number of columns as argument and designs the whole layout (at least the part directly related to my dropdowns). I could, then, create a callback to update this part of the layout and that seems ok to me. The challenge here is to set all the layout parameters correctly, once the div’s division depends on how many columns my table has, as I said. Has anyone tried anything like that? Sorry if there’s already a topic on it, but I haven’t really found it. Thank you!

Function to update layout dynamically

Sounds like the right way to do it. See the second part of Live Updates | Dash for Python Documentation | Plotly - if app.layout is a function, then it will get called on every page load, allowing your app to be more dynamic.

1 Like