How to add a column that has hyperlink as buttons for each row in datatable

How can I add a column that has 2 hyperlink as buttons for each row in data table

I can have a shared callback routine for those two buttons

image

Hi @yogi_dhiman ,

This might be interesting:

1 Like

Hi,

I’ll add to this query as well. I know how to use the active cell dictionary and how that can trigger particular callbacks.

Like the original poster, I would want a column that you can embed a button or a link that triggers a completely different callback.

I suppose what I could do is create a callback when that particular column is selected. I suppose it would be

# This is pseudocode - I'm just typing it directly in the textbox so if you copy and paste and it doesn't work. Sorry.
@app.callback(
    Output('my_target_id', 'my_target_param'),
    Input('table', 'active_cell')
)
def trigger_settings_menu(active_cell):
    try:
        col = active_cell['column_id']
    except TypeError:
        raise exceptions.PreventUpdate

    if active_cell['column_id'] == 'settings_column':
        return target_param_setting_i_want_to_change_or_trigger_to_go_to_settings_page

With the above, each column would have a “hyperlink” that doesn’t actually do anything. It would merely look like a hyperlink to show people that they can click on it. When they click on the cell, it triggers the above logic.

So each setting would require it’s own column as it is operating on the column ID.


So I wonder then if we could create a column of icon buttons - where a n_click on any of them triggers the above value look-up logic?

The issues with that is that each button would need to have it’s own ID (which could be iteratively assigned by the row number on each callback refresh/pagination click) and then you would need to listen to each Input in the function.

Unless…


Create a global button n_click variable that will += 1 the global variable with the array of buttons listed above. So each subsequent callback that needs to listen to that particular array of buttons only needs to listen to the one variable input, not a massive array of buttons in the signature each and every time.

But I suppose we would need a Dash object to have the Callback output to. So, just a “button” that isn’t actually in the layout?

settings_button_array = dbc.Button('No one is going to see this anyway', id='settings_button_array', n_clicks=0)

@app.callback(
    Output('settings_button_array', 'n_clicks'),
    [State('settings_button_array', 'n_clicks',
    Input('settings_button_1', 'n_clicks'),
    Input('settings_button_2', 'n_clicks'),
    Input('settings_button_3', 'n_clicks')]    # And so on and so forth.
)
def button_array_update(array_nclick, settings1, settings2, settings3):
    array_nclick += 1
    return array_nclick

Just how you would deal with the settings_button1, settings_button2 I’m not completely sure of.

@MrMadium you might find this post helpful: