ag-grid: "How to scroll to last known position"?

Update for Release 23.1.0 (1st May 2020)+

Use immutableData=true instead of deltaRowDataMode=true


In typical AG fashion they hide this vital piece of information in their docs:

Method 3 - Delta Row Data The delta method is using the row data method above but having the property deltaRowDataMode=true.

When deltaRowDataMode is on, the grid will compare the new row data with the current row data and create a transaction object for you. The grid then executes the change as an update transaction, keeping all of the grids selections, filters etc.

Use this if you want to manage the data outside of the grid (eg in a Redux store) and then let the grid work out what changes are needed to keep the grid's version of the data up to date.

https://www.ag-grid.com/javascript-grid-data-update/#bulk-updating

This in my opinion should be a setting you always use if your rows have a unique ID (I hope they do, it's good practice to do it). Set deltaRowDataMode to true and use getRowNodeId to specify a unique id for the row.

After that your grid will update much more efficiently (only updating what is needed) and it won't jump to the top when it does as it's not re-creating every row and cell in the grid on an update.

For good measure you could also add the suppressScrollOnNewData option, though I'm not sure if it's needed if you do the above.


Thanks a million, to spare some time to everybody here's what you have to pass to the propery [gridOptions]. As long as your data has an unique ID you're set.

// gridOptions
{
    ...,
    deltaRowDataMode: true,
    getRowNodeId: function (data) {
        return data.id;
    },
},