# Dash DataTable - Support for Click Events

**URL:** <https://community.plotly.com/t/dash-datatable-support-for-click-events/7878>\
**Category:** Dash Python\
**Created:** [January 21, 2018, 5:54pm UTC](https://community.plotly.com/t/dash-datatable-support-for-click-events/7878 "2018-01-21T17:54:04Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![kagaev](https://avatars.discourse-cdn.com/v4/letter/k/839c29/32.png) [@kagaev](https://community.plotly.com/u/kagaev)\
**Post date:** [January 21, 2018, 5:54pm UTC](https://community.plotly.com/t/dash-datatable-support-for-click-events/7878/1 "2018-01-21T17:54:04Z")

</div>

Hi all.

Question about the new DataTable: is it possible to return ‘clickData’ for table cells and rows in the same way as one can for charts? This could potentially make interacting with tables better and more fluid, e.g. after clicking we could create and update secondary charts and tables based on the column-header and row-values of the cell.

Apologies if i ask this question in the wrong forum (new to Dash and the forums).

But in either case, great job creating Dash!

---

<div class="post-metadata">

**Author:** ![chriddyp](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/chriddyp/32/16855_2.png) [@chriddyp](https://community.plotly.com/u/chriddyp)\
**Post date:** [January 22, 2018, 5:01pm UTC](https://community.plotly.com/t/dash-datatable-support-for-click-events/7878/2 "2018-01-22T17:01:19Z")

</div>

> [@kagaev](#):
>
> is it possible to return ‘clickData’ for table cells and rows in the same way as one can for charts?

This is not possible right now. However, once something like this this [https://github.com/plotly/dash-table-experiments/pull/11](https://github.com/plotly/dash-table-experiments/pull/11) is merged in, you could render certain cells as buttons and listen to those click events.

---

<div class="post-metadata">

**Author:** ![kagaev](https://avatars.discourse-cdn.com/v4/letter/k/839c29/32.png) [@kagaev](https://community.plotly.com/u/kagaev)\
**Post date:** [January 23, 2018, 5:14pm UTC](https://community.plotly.com/t/dash-datatable-support-for-click-events/7878/3 "2018-01-23T17:14:25Z")

</div>

Thanks for the quick clarification. Thats definitely a step in the right direction. In the meantime i think i will use dropdowns to specify the x and y values from the original table in order to create a new one.

---

<div class="post-metadata">

**Author:** ![DataArtist](https://avatars.discourse-cdn.com/v4/letter/d/ecb155/32.png) [@DataArtist](https://community.plotly.com/u/DataArtist)\
**Post date:** [October 24, 2019, 7:54pm UTC](https://community.plotly.com/t/dash-datatable-support-for-click-events/7878/4 "2019-10-24T19:54:45Z")

</div>

Hi @chriddyp, are there any updates on getting click events from the rows of the datatable? thank you very much!

---

<div class="post-metadata">

**Author:** ![chriddyp](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/chriddyp/32/16855_2.png) [@chriddyp](https://community.plotly.com/u/chriddyp)\
**Post date:** [October 25, 2019, 12:36am UTC](https://community.plotly.com/t/dash-datatable-support-for-click-events/7878/5 "2019-10-25T00:36:53Z")

</div>

Try the `active_cell` property ([https://dash.plot.ly/datatable/reference](https://dash.plot.ly/datatable/reference)).

---

<div class="post-metadata">

**Author:** ![DataArtist](https://avatars.discourse-cdn.com/v4/letter/d/ecb155/32.png) [@DataArtist](https://community.plotly.com/u/DataArtist)\
**Post date:** [December 3, 2019, 9:34pm UTC](https://community.plotly.com/t/dash-datatable-support-for-click-events/7878/6 "2019-12-03T21:34:05Z")

</div>

Thank you, @chriddyp, that is helpful, but what about Double-Clicks?

---

<div class="post-metadata">

**Author:** ![BadCode](https://avatars.discourse-cdn.com/v4/letter/b/a8b319/32.png) [@BadCode](https://community.plotly.com/u/BadCode)\
**Post date:** [February 2, 2020, 8:34am UTC](https://community.plotly.com/t/dash-datatable-support-for-click-events/7878/7 "2020-02-02T08:34:21Z")

</div>

@chriddyp

following link contains an [example](https://community.plotly.com/t/datatable-accessing-value-of-active-cell/20378/3) for active\_cell,

I am looking for how to get row\_id on active\_cell event?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![mjk7ha](https://avatars.discourse-cdn.com/v4/letter/m/e99b99/32.png) [@mjk7ha](https://community.plotly.com/u/mjk7ha)\
**Post date:** [April 20, 2020, 7:37pm UTC](https://community.plotly.com/t/dash-datatable-support-for-click-events/7878/8 "2020-04-20T19:37:35Z")

</div>

Anyone knows if this exists? Or still no information on that?

---

<div class="post-metadata">

**Author:** ![jack](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jack/32/11_2.png) [@jack](https://community.plotly.com/u/jack)\
**Post date:** [September 3, 2021, 11:48pm UTC](https://community.plotly.com/t/dash-datatable-support-for-click-events/7878/9 "2021-09-03T23:48:37Z")

</div>

Here’s a simple working example for Click Events with Dash DataTable:

You can run it here: [https://replit.com/@jackparmer1/NarrowAccomplishedDividend#main.py](https://replit.com/@jackparmer1/NarrowAccomplishedDividend#main.py)

Code:

```auto
import dash
import dash_table as dt
import pandas as pd
import dash_bootstrap_components as dbc
import json
from dash.dependencies import Input, Output

df = pd.read_csv('https://git.io/Juf1t')

app = dash.Dash(external_stylesheets=[dbc.themes.BOOTSTRAP])

app.layout = dbc.Container([
    dbc.Label('Click a cell in the table:'),
    dt.DataTable(
        id='tbl', data=df.to_dict('records'),
        columns=[{"name": i, "id": i} for i in df.columns],   
    ),
    dbc.Alert("Click the table", id='out'),
])

@app.callback(
    Output('out', 'children'),
    Input('tbl', 'active_cell'))
def update_graphs(active_cell):
  return json.dumps(active_cell)

if __name__ == " __main__":
    app.run_server(host='0.0.0.0', port=5000, debug=True)

```

 ![image](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/4/2/427d19118f759d8b820ffb2a169b2a4302a8ec36.png)

---

<div class="post-metadata">

**Author:** ![Rusty\_Shackleford](https://avatars.discourse-cdn.com/v4/letter/r/ee7513/32.png) [@Rusty\_Shackleford](https://community.plotly.com/u/Rusty_Shackleford)\
**Post date:** [June 15, 2022, 4:12pm UTC](https://community.plotly.com/t/dash-datatable-support-for-click-events/7878/10 "2022-06-15T16:12:28Z")

</div>

Hello,  
Could the active\_cell property be used to display plots from two different data frames in a Dash app? This would depend on which column of the data table that’s clicked. Thanks in advance!

---

<div class="post-metadata">

**Author:** ![AnnMarieW](https://avatars.discourse-cdn.com/v4/letter/a/ec9cab/32.png) [@AnnMarieW](https://community.plotly.com/u/AnnMarieW)\
**Post date:** [June 15, 2022, 6:34pm UTC](https://community.plotly.com/t/dash-datatable-support-for-click-events/7878/11 "2022-06-15T18:34:47Z")

</div>

Hi @Rusty_Shackleford and welcome to the Dash community 🙂

You might find this post helpful: [Button inside a Dash Table - #5 by AnnMarieW](https://community.plotly.com/t/button-inside-a-dash-table/51460/5)

---

<div class="post-metadata">

**Author:** ![Rusty\_Shackleford](https://avatars.discourse-cdn.com/v4/letter/r/ee7513/32.png) [@Rusty\_Shackleford](https://community.plotly.com/u/Rusty_Shackleford)\
**Post date:** [June 15, 2022, 7:08pm UTC](https://community.plotly.com/t/dash-datatable-support-for-click-events/7878/12 "2022-06-15T19:08:28Z")

</div>

Hello @AnnMarieW, yes I am making a dashboard using the cell\_clicked function and the active\_cell property. Let’s take your example of the “countries” app displaying graphs such as ‘life expectancy’ and ‘gdp’ by country. Do you think it would be feasible to use such a function to output graphs from two different data frames? Say if ‘life expectancy’ and ‘gdp’ were contained in two separate pandas data frames that could not be combined due to formatting differences?

---

<div class="post-metadata">

**Author:** ![AnnMarieW](https://avatars.discourse-cdn.com/v4/letter/a/ec9cab/32.png) [@AnnMarieW](https://community.plotly.com/u/AnnMarieW)\
**Post date:** [June 15, 2022, 7:13pm UTC](https://community.plotly.com/t/dash-datatable-support-for-click-events/7878/13 "2022-06-15T19:13:52Z")

</div>

@Rusty_Shackleford  
I’m not sure exactly what you are getting at. If you use the active cell to trigger the callback, you can use two different dataframes in the callback to create the data to update one or more figures.

If you post a minimal example I might be able to help more.

---

<div class="post-metadata">

**Author:** ![MishaR](https://avatars.discourse-cdn.com/v4/letter/m/5fc32e/32.png) [@MishaR](https://community.plotly.com/u/MishaR)\
**Post date:** [July 15, 2024, 7:56pm UTC](https://community.plotly.com/t/dash-datatable-support-for-click-events/7878/14 "2024-07-15T19:56:10Z")

</div>

The problem with Jack’s approach is that nothing happens when you click on a cell which is already active. Anyone has a better idea?

---

<div class="post-metadata">

**Author:** ![AnnMarieW](https://avatars.discourse-cdn.com/v4/letter/a/ec9cab/32.png) [@AnnMarieW](https://community.plotly.com/u/AnnMarieW)\
**Post date:** [July 16, 2024, 2:03am UTC](https://community.plotly.com/t/dash-datatable-support-for-click-events/7878/15 "2024-07-16T02:03:56Z")

</div>

Hi @MishaR and welcome to the Dash communty 🙂

You are correct - the DataTable does not support click events.  
I recommend using Dash AG Grid instead. Here is an example of how to select a cell:

> **[Cell Selection | Dash for Python Documentation | Plotly](https://dash.plotly.com/dash-ag-grid/cell-selection)**
>
> Trigger callbacks by clicking on a cell and disable cell focus

You can also have buttons and other components in cells:

> **[Cell Renderer Components | Dash for Python Documentation | Plotly](https://dash.plotly.com/dash-ag-grid/cell-renderer-components#example-2:-button-component-with-callback)**
>
> Cell renderer components in Dash AG Grid

---

<div class="post-metadata">

**Author:** ![MishaR](https://avatars.discourse-cdn.com/v4/letter/m/5fc32e/32.png) [@MishaR](https://community.plotly.com/u/MishaR)\
**Post date:** [July 18, 2024, 4:45pm UTC](https://community.plotly.com/t/dash-datatable-support-for-click-events/7878/16 "2024-07-18T16:45:25Z")

</div>

Thank you, @AnnMarieW ! I’ll give this a try,.
