Search code examples
python-3.xplotlydashboardplotly-dash

dash button with varying input to url output


I have a table in my dashboard which has a lot of different “name” values, I’d like to have button somewhere that when a name is selected and the button is pushed, it will navigate to a URL that contains that name. For example:

   name  ID         status
[] mike  a823hjsad  OK
[] sam   9saksndk9  –
[] alex  0274dhskx  OK

[BUTTON]

when I have selected ‘mike’, and pressed the [BUTTON] I would like a new tab to open and direct to the url “https://www.google.com/search?q=mike”. but the last part of the URL will change depending on which name is selected.

I hope this makes sense, I am still very new to dash and it seems like there are so many different ways of integrating html links into a dashboard.


Solution

  • This would not be too hard with the Dash data table. Specifically, see this section of the docs about the active_cell property. You could use that as a State value for your callback, and the button as the Input. It should work just like you're describing.