# Auto-scroll to the selected row for Dash Datatable

**URL:** <https://community.plotly.com/t/auto-scroll-to-the-selected-row-for-dash-datatable/58783>\
**Category:** Dash Python\
**Created:** [November 26, 2021, 9:42am UTC](https://community.plotly.com/t/auto-scroll-to-the-selected-row-for-dash-datatable/58783 "2021-11-26T09:42:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rkiuchir](https://avatars.discourse-cdn.com/v4/letter/r/ad7895/32.png) [@rkiuchir](https://community.plotly.com/u/rkiuchir)\
**Post date:** [November 26, 2021, 9:42am UTC](https://community.plotly.com/t/auto-scroll-to-the-selected-row-for-dash-datatable/58783/1 "2021-11-26T09:42:11Z")

</div>

Hi there,

Is there any way to perform auto-scroll to the selected row for Datatable?  
I’ve found a similar question posted a few years ago, but it seems not solved yet:  
[https://community.plotly.com/t/programatically-set-scrolling-point-for-dash-datatable/7881](https://community.plotly.com/t/programatically-set-scrolling-point-for-dash-datatable/7881)

What I’m trying is to monitor the log data which needs to be displayed in thousands of rows, and it may great to have such a feature.

Here is my simple try code:

```auto
import dash
import dash_table
import pandas as pd
from collections import OrderedDict
from dash import html, dcc
from dash.dependencies import Input, Output

app = dash.Dash( __name__ )

df = pd.DataFrame(OrderedDict(
    [
        [
            'Column {}'.format(i + 1), list(range(5000))
        ] for i in range(15)
    ]
))

app.layout = html.Div(children=[
    dash_table.DataTable(
        id = 'table',
        data=df.to_dict('records'),
        columns=[{'id': c, 'name': c} for c in df.columns],
        cell_selectable=True,
        row_selectable='multi',
        selected_rows=[0],
        virtualization=True,
        fixed_rows={'headers': True},
        style_cell={'minWidth': 95, 'width': 95, 'maxWidth': 95},
        style_table={'height': 3000}, # default is 500
        page_size=5000,
    ),
    dcc.Input(
        id='input',
        type='number',
        value=1
    )

])

@app.callback(
    Output('table', 'selected_rows'),
    Output('table', 'active_cell'),
    Input('input', 'value')
)
def update_table(value):
    return [value], {'row': value, 'column': 1}

if __name__ == ' __main__':
    app.run_server(debug=True)

```

I already confirmed that “selected\_rows” and “active\_cell” work fine based on this code.

 ![image](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/1/2/121d9ddaef3d4a4ed98af0a923f6ce696a49279a.png)

FYI, my dash version is 2.0.0.

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![sibo](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/sibo/32/24964_2.png) [@sibo](https://community.plotly.com/u/sibo)\
**Post date:** [August 1, 2023, 7:36pm UTC](https://community.plotly.com/t/auto-scroll-to-the-selected-row-for-dash-datatable/58783/2 "2023-08-01T19:36:31Z")

</div>

up! any updates? this feature would be great to have!

---

<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:** [August 1, 2023, 8:10pm UTC](https://community.plotly.com/t/auto-scroll-to-the-selected-row-for-dash-datatable/58783/3 "2023-08-01T20:10:46Z")

</div>

This isn’t possible in the Dash Data Table, but with Dash AG Grid, you can specify a Scroll To row:

> **[Scroll To | Dash for Python Documentation | Plotly](https://dash.plotly.com/dash-ag-grid/scroll-to)**
>
> Scroll to row in Dash AG Grid

You could also do a “post-sort” to place all the selected rows at the top:

> [@How to sort dash table so selected rows are always first?](https://community.plotly.com/t/how-to-sort-dash-table-so-selected-rows-are-always-first/77159/2):
>
> Hi @dowens1994 and welcome to the Dash community slight_smile This isn’t easy to do with the Dash DataTable, but give dash-ag-grid a try! Here is an example in the docs that does a post sort and places certain rows at the top. You can modify this example in the link above to make selected rows at the top. Check this out:: [ag-grid-sort-selected-top] import dash\_ag\_grid as dag from dash import Dash, html import pandas as pd app = Dash(\_\_name\_\_) df = pd.read\_csv( "https://raw.git…
