Ag_grid scrollTo

Hello,
I am working with the ag_grid scrollTo property and I have run into the following trouble :

  • whenever I modify a cell, I update my databse and download back all the value of my database and use scrollTo to go back to the originally modified row => this parts work
  • If I click again on another row of the grid, my grid will scoll again back to the first modified row.
    This is really annoying for users.

I went to see the example there Scroll To | Dash for Python Documentation | Plotly, but it seems like example have the same behavior : once user has scrolled to a row, the grid will scroll gain to that row if you double click somewhere else on the grid.
Would that be a bug, or is it something I am doing wrong ?
Thank you

Hi @eghza

Thanks for reporting!

I’ve opened an issue on GitHub for this: scrollTo previous · Issue #312 · plotly/dash-ag-grid · GitHub

In the meantime, a workaround might be to do this with the grid’s API https://www.ag-grid.com/react-data-grid//grid-api/#reference-scrolling-ensureIndexVisible

3 Likes

This looks to be do to an issue with scrollTo not resetting its value after being applied.

You can reset it manually if you would like to do so, however, that will obviously take a clientside callback.

@AnnMarieW’s suggestion is right that you can use the api to perform the same task.

2 Likes

Thanks a lot for your help. I managed to do that with a clientside callback :slight_smile:

clientside_callback(
    """
    function (rowId,gridId) {
       gridApi = dash_ag_grid.getApi(gridId)
       gridApi.ensureIndexVisible(rowIndex=rowId, rowPosition='middle');
       return window.dash_clientside.no_update;
    }
    """,
    Output(ids.my_grid(MATCH), "id"),
    Input(ids.entry(MATCH), "value"),
    State(ids.my_grid(MATCH), "id"),
    prevent_initial_call=True,
    )
2 Likes